[Python-Dev] new buffer in python2.7

Kristján Valur Jónsson kristjan at ccpgames.com
Wed Oct 27 04:13:12 CEST 2010

Although 2.7 has the new buffer interface and memoryview objects, these are widely not accepted in the built in modules.
Examples are the structmodule, some of the socketmodule apis, structmodule, etc.

IMHO this is unfortunate.  For example when doign network io, you would want code like this:
Buffer = bytearray(10)
Header = struct.unpack("i", memoryview(Buffer)[:4])[0]

In other words, you want to minimize coping the data around.  Currently in 2.7 you have to cast the memoryview to str() which copies the data.  In 3.0 you don't.
Is there any chance of getting changes like these in ?
(swapping s# for s* in PyArg_ParseTuple in a few strategic places)

My current list of places would be:

audioop.c and imageop.c are probably less important.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20101027/333f5ffb/attachment.html>

More information about the Python-Dev mailing list