how to get bytes from bytearray without copying

Juraj Ivančić juraj.ivancic at gmail.com
Mon Mar 3 04:09:56 EST 2014


On 3.3.2014. 2:27, Ian Kelly wrote:

> Python 3.3 has a C API function to create a memoryview for a char*,
> that can be made read-only.
>
>      http://docs.python.org/3/c-api/memoryview.html#PyMemoryView_FromMemory

Yes, this is probably what I'll do in absence of pure Python solution. 
Thanks for the tip.

> Or you could bite the bullet and copy everything
> once at the start to create a bytes object, and then never have to
> worry about it again.

That would be a surrender :-)




More information about the Python-list mailing list