[issue3132] implement PEP 3118 struct changes
Pauli Virtanen
report at bugs.python.org
Thu Dec 2 19:14:19 CET 2010
Pauli Virtanen <pav at iki.fi> added the comment:
For reference, Numpy's PEP 3118 implementation is here:
http://github.com/numpy/numpy/blob/master/numpy/core/_internal.py#L357
http://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/buffer.c#L76
It would be a good idea to ensure that the numpy and struct implementations are in agreement about details of the format strings.
(I wouldn't take the Numpy implementation as the definitive one, though.)
- The "sub-structs" in Numpy arrays (in align=True mode) are aligned
according to the maximum alignment of the fields.
- I assumed the 'O' format in the PEP is supposed to be similar to Numpy
object arrays. This implies some reference counting semantics. The
Numpy PEP 3118 implementation assumes the memory contains borrowed
references, valid at least until the buffer is released.
Unpacking 'O' should probably INCREF whatever PyObject* pointer is
there.
- I assumed the alignment specifiers were unscoped. I'm not sure
however whether this is the best thing to do.
- The function pointers and pointers to pointers were not implemented.
(Numpy cannot represent those as data types.)
----------
nosy: +pv
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3132>
_______________________________________
More information about the Python-bugs-list
mailing list