This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lemburg
Recipients lemburg, loewis, pitrou, vstinner
Date 2010-05-28.12:39:40
SpamBayes Score 0.000999654
Marked as misclassified No
Message-id <>
In-reply-to <>
Antoine Pitrou wrote:
> Antoine Pitrou <> added the comment:
>> Any Python object can expose a buffer interface and the above
>> functions then allow accessing these interfaces from within
>> Python.
> What's the point? The codecs functions already support objects exposing the buffer interface:
>>>> b = b"\xe9"
>>>> codecs.latin_1_decode(memoryview(b))
> ('é', 1)
>>>> codecs.latin_1_decode(array.array("b", b))
> ('é', 1)
> Those two functions are undocumented. They serve no useful purpose (you can call the bytes(...) constructor instead, or even use the buffer object directly as showed above). They are badly named since they don't have anything to do with codecs. Google Code Search shows them not appearing anywhere else than implementations of the Python stdlib. Removing them only seems reasonable.

readbuffer_encode and charbuffer_encode convert objects to bytes
and provide a codec encoder interface for this, hence the naming.

They are meant to be used as encode methods for codecs, just like
the other *_encode functions exposed in the _codecs module, e.g.

class BinaryDataCodec(codecs.Codec):

    # Note: Binding these as C functions will result in the class not
    # converting them to methods. This is intended.
    encode = codecs.readbuffer_encode
    decode = codecs.latin_1_decode

While it's possible to emulate the functions via other methods,
these methods always introduce intermediate objects, which isn't
necessary and only costs performance.

Given than "t#" was basically rendered useless in Python3 (see
issue8839), removing charbuffer_encode() is indeed possible,

+1 on removing charbuffer_encode()
-1 on removing readbuffer_encode()
Date User Action Args
2010-05-28 12:39:42lemburgsetrecipients: + lemburg, loewis, pitrou, vstinner
2010-05-28 12:39:40lemburglinkissue8838 messages
2010-05-28 12:39:40lemburgcreate