Message151537
Revisiting memoryview.size: I foresee problems for NumPy users, since array.size
has a different meaning there:
>>> x = array([[1,2,3], [4,5,6]], dtype='q')
>>> x.shape
(2, 3)
>>> x.itemsize
8
>>> len(x)
2
>>> x.size
6
>>> x.nbytes
48
So here we have:
x.nbytes == product(shape) * itemsize == Py_buffer.len == (virtual!) byte length
x.size == product(shape) == number of elements
My suggestion is to use memoryview.nbytes as well. memoryview.size would have
the additional problem that Py_buffer.len is always the byte size of the logical
structure (e.g. after slicing) and not necessarily the byte size of the physical
memory area. |
|
Date |
User |
Action |
Args |
2012-01-18 13:34:54 | skrah | set | recipients:
+ skrah, teoliphant, paul.moore, mark.dickinson, ncoghlan, rupole, pitrou, kristjan.jonsson, vstinner, pv, jcon, petri.lehtinen |
2012-01-18 13:34:54 | skrah | set | messageid: <1326893694.59.0.983687342873.issue10181@psf.upfronthosting.co.za> |
2012-01-18 13:34:54 | skrah | link | issue10181 messages |
2012-01-18 13:34:53 | skrah | create | |
|