[portland] Raw buffers in python

Benjamin van der Veen b at bvanderveen.com
Tue Nov 1 00:30:55 CET 2011


Hey all,

What's the best way to make a raw buffer out of a string in Python? They
key requirement is that inspecting a range of characters in the resulting
object does not cause a copy/allocation. Correct me if I'm wrong, but it
seems like sequence types (produced by memoryview, bytearray, etc) all
return a character or integer object when you access items by index.

An example usecase is a parser—you have a string buffer the user gave you,
and you're iterating over each character. It would be nice not to allocate
a heap object for every iteration.

Hm, although, now that I'm typing this up, I'm realizing it might be a bit
ridiculous to be asking for a raw char or int in Python. :S

Best,
Benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/portland/attachments/20111031/31c13765/attachment.html>


More information about the Portland mailing list