[issue8922] Improve encoding shortcuts in PyUnicode_AsEncodedString()

Marc-Andre Lemburg report at bugs.python.org
Tue Jun 8 00:05:30 CEST 2010


Marc-Andre Lemburg <mal at egenix.com> added the comment:

STINNER Victor wrote:
> 
> STINNER Victor <victor.stinner at haypocalc.com> added the comment:
> 
>> the shortcuts were meant for Python internal use only
> 
> str.encode() calls PyUnicode_AsEncodedString() and bytes.decode() calls PyUnicode_Decode(), so it is not for internal use only. Eg. "text".encode("ASCII") doesn't use the fastpath.

Right. As I said: the *shortcuts* are meant for internal use
only. External code should not rely on them, but can, of course,
use those canonical names as well.

Note that these shortcut bypass the codec registry logic. Codec
search functions cannot redirect these shortcuts to their
own implementations, so we have to be careful about adding more
such shortcuts.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8922>
_______________________________________


More information about the Python-bugs-list mailing list