[Python-Dev] The buffer() function (original) (raw)

Thomas Heller theller at python.net
Thu Jul 13 19:38:28 CEST 2006


Fredrik Lundh schrieb:

Thomas Heller wrote:

Naturally I tried to call base64.encodestring(buffer(ctypesinstance)) and it worked, so that was my answer. >> does ctypesinstance implement the buffer API ? if it does, is the buffer() call even necessary ? Yes, in both cases. are you sure? does it implement the bfgetreadbuffer slot? afaik, afaicr, and from what I can tell by looking briefly at the sources, the binascii.b2abase64 function uses the the s# marker, and that argument type accepts strings and read only buffers, right away. no extra crud should be necessary.

Yes, for binascii.b2a_base64 you are right: bf_getreadbuffer is sufficient. For binascii.b2a_hex (for example), it is not sufficient.

But that was not the question. What about the status of the buffer function?

All the above functions accept a buffer object.

Thomas



More information about the Python-Dev mailing list