Message203380
| Author |
vstinner |
| Recipients |
doerwalter, ezio.melotti, lemburg, ncoghlan, serhiy.storchaka, vstinner |
| Date |
2013年11月19日.14:27:23 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1384871243.26.0.0846102721639.issue19619@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
+ /* A set would be faster, but when to build it, where to store it? */
+ if (_PyUnicode_CompareWithId(codec_name, &PyId_base64) == 0 ||
+ _PyUnicode_CompareWithId(codec_name, &PyId_uu) == 0 ||
+ _PyUnicode_CompareWithId(codec_name, &PyId_quopri) == 0 ||
+ _PyUnicode_CompareWithId(codec_name, &PyId_hex) == 0 ||
+ _PyUnicode_CompareWithId(codec_name, &PyId_bz2) == 0 ||
+ _PyUnicode_CompareWithId(codec_name, &PyId_zlib) == 0 ||
+ PyUnicode_CompareWithASCIIString(codec_name, "rot-13") == 0
+ ) {
+ is_text_codec = 0;
+ }
This is slow and not future proof. It would be faster and simpler to have two registries: a register only for bytes.decode()/str.encode() and another for "custom codecs" for codecs.encode/decode (or (bytes|str).transform()/untransform()).
So "abc".encode("rot13") would simply fail with a LookupError. |
|