This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mpb
Recipients mpb
Date 2013-11-14.00:39:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1384389557.7.0.405119332815.issue19577@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2013-11-14 00:39:17mpbsetrecipients: + mpb
2013-11-14 00:39:17mpbsetmessageid: <1384389557.7.0.405119332815.issue19577@psf.upfronthosting.co.za>
2013-11-14 00:39:17mpblinkissue19577 messages
2013-11-14 00:39:17mpbcreate