[SciPy-user] numpy array in ctype struct
Travis E. Oliphant
Tue Jan 15 17:01:25 CST 2008
Thomas Heller wrote:
> Travis E. Oliphant schrieb:
>> Thomas Heller wrote:
>>> Travis E. Oliphant schrieb:
>>>> You can create an array from a pointer to memory and a
>>>> description of the data that is much like the ctypes structure. At
>>>> some point, there should be a direct conversion from ctypes objects to
>>>> NumPy data-types, but nobody has written that yet.
>>> Is there anything that should be added to ctypes (Python 2.6 isn't too
>>> far away) that would help with this conversion?
>> One approach would for ctypes objects to describe their data-type using
>> the new additions to the struct syntax (i.e. fully support the new
>> buffer interface including data-type description as defined in PEP
>> 3118). This should be going in Python 2.6 as well (but I need help in
>> the implementation).
>> Then, NumPy arrays will support consuming the syntax as well and it
>> should be an easy thing to pass back and forth between NumPy array views
>> and ctypes-objects views of memory. I think such a thing would be very
> I assume the implementation would have to take place in the py3k branch,
> and later it would (hopefully) be ported to the trunk?
> Do I understand correctly that __array_interface__ and __array_struct__
> are superseeded by what's in PEP 3118, or are these only out of scope for the PEP?
They are superseded. We will have them for a while in the NumPy world,
but PEP 3118 is the right concept going forward as it is in the Python
More information about the SciPy-user