[issue19577] memoryview bind (the opposite of release)

2014-10-14 Thread Stefan Krah
Changes by Stefan Krah : -- nosy: -skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.o

[issue19577] memoryview bind (the opposite of release)

2013-11-15 Thread Stefan Krah
Stefan Krah added the comment: To my surprise, this line is 10% faster with a freelist: ./python -m timeit -s "import array; a = array.array('B', [0]*100); m = memoryview(a)" "m[30:40]" I think the reason is that PyObject_GC_NewVar() is quite slow. -- ___

[issue19577] memoryview bind (the opposite of release)

2013-11-14 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue19577] memoryview bind (the opposite of release)

2013-11-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Yes, I also doubt this would actually bring anything significant, which is why I asked for numbers :-) Python creates many objects in a very intensive fashion, and memoryview are not, by far, the most common object type. -- ___

[issue19577] memoryview bind (the opposite of release)

2013-11-14 Thread Stefan Krah
Stefan Krah added the comment: You could experiment with multiple freelists, one for each ndim. I'm skeptical however that the gain will be substantial. I've tried freelists for _decimal and the gain was in the order of 2% (not worth it). -- ___ Pytho

[issue19577] memoryview bind (the opposite of release)

2013-11-14 Thread Stefan Krah
Stefan Krah added the comment: -1 on complicating the code further. It would be possible to pass an existing memoryview to mbuf_add_view(). That would save the line mv = memory_alloc(). But: a) You need to check that ndim is correct (shape, strides and suboffsets are allocated via th

[issue19577] memoryview bind (the opposite of release)

2013-11-13 Thread mpb
mpb added the comment: It would be nice in terms of avoiding malloc()s and free()s. I could estimate it in terms of memoryview creations per message parse. I'll be creating 10-20 memoryviews to parse each ~100 byte message. So... I guess I'd have to build a test to see how long a memoryview

[issue19577] memoryview bind (the opposite of release)

2013-11-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: > In the context of the above example, I think it might be nice if I > could rebind an existing memoryview to a new object. It would be nice how so? Can you try to estimate the speed gain? -- nosy: +pitrou ___ Python

[issue19577] memoryview bind (the opposite of release)

2013-11-13 Thread mpb
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/