[New-bugs-announce] [issue19577] memoryview bind (the opposite of release)
mpb
report at bugs.python.org
Thu Nov 14 01:39:17 CET 2013
New submission from mpb:
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)
----------
messages: 202806
nosy: mpb
priority: normal
severity: normal
status: open
title: memoryview bind (the opposite of release)
type: enhancement
versions: Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19577>
_______________________________________
More information about the New-bugs-announce
mailing list