STINNER Victor added the comment:
+ /* 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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue19619>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com