Message202806
I'm writing Python code to parse binary (byte oriented) data.
I am (at least somewhat) aware of the performance implications of various approaches to doing the parsing. With performance in mind, I would like to avoid unnecessary creation/destruction/copying of memory/objects.
An example:
Let's say I am parsing b'0123456789'.
I want to extract and return the substring b'234'.
Now let's say I do this with memoryviews, to avoid unnecessary creation and copying of memory.
m0 = memoryview (b'0123456789')
m1 = m0[2:5] # m1 == b'234'
Let's say I do this 1000 times. Each time I use readinto to load the next data into m0. So I can create m0 only once and reuse it.
But if the relative position of m1 inside m0 changes with each parse, then I need to create a new m1 for each parse.
In the context of the above example, I think it might be nice if I could rebind an existing memoryview to a new object. For example:
m0 = memoryview (b'0123456789')
m1.bind (m0, 2, 5) # m1 == b'234'
Is this an idea worth considering?
(Possibly related: Issue 9789, 9757, 3506; PEP 3118) |
|
Date |
User |
Action |
Args |
2013-11-14 00:39:17 | mpb | set | recipients:
+ mpb |
2013-11-14 00:39:17 | mpb | set | messageid: <1384389557.7.0.405119332815.issue19577@psf.upfronthosting.co.za> |
2013-11-14 00:39:17 | mpb | link | issue19577 messages |
2013-11-14 00:39:17 | mpb | create | |
|