[Python-Dev] Expose the array interface in Python 2.5?

Travis E. Oliphant oliphant.travis at ieee.org
Sun Mar 19 06:32:44 CET 2006


Paul Moore wrote:
> On 3/17/06, Thomas Heller <theller at python.net> wrote:
> 
>> Travis E. Oliphant wrote:
>>> Would it be possible to add at least the C-struct array interface to the
>>> Python arrayobject in time for Python 2.5?
>> I'm very much for that.
>>
>>> Is someone on this list willing to help make it happen?
>> Unfortunately not me - I'm too busy with ctypes, and if the array interface
>> makes it into the core I will have to implement/use that in ctypes too.

The ctypes interface is also another reason I really want a basic array 
interface into the core.

As the very clever people on this list noticed, I was actually asking 
two different things because I was really looking for support from 
people who wanted either one...

What I would really like to see is a very-simple C-object defined 
(perhaps not even exposed to the Python user but only the 
extension-module writer).

This C-object would have the structure of NumPy arrays, be inheritable, 
and define an __array_struct__ method (notice I'm not even asking at 
this point for a new function-pointer table like the buffer protocol has 
--- although I think at some point that could be useful and maybe it is 
even better right now to push for that).

The purpose of the C-object would be so that all extension writers to 
Python can rely on a simple but general-purpose description of an array 
that Numeric has established over the past decade.

This C-object already has been somewhat fleshed out and the only real 
work would be to add support for it on other objects.

> If all that is required is a simple C definition added to the Python
> code, then it seems to me that would be (a) fairly easy, but (b)
> pretty useless (on the basis that a standards-style PEP like the DB
> API ones would do much the same, without any code changes).

I think I would like to see a real object that can be inherited from (at 
least in C extension modules).  Again perhaps in Python 2.5, this object 
is not even intentionally exposed to the Python level.

> 
> On the third hand, the PEP referenced from the page you quote (at
> http://svn.scipy.org/svn/PEP/PEP_genarray.txt) seems to specify an
> implementation - are you just asking for that to be added to the core?
> If so, why not submit this as a formal PEP, and see what happens from
> there? (For this route, one of the Numeric people *needs* to champion
> the PEP, IMHO, as only they are qualified to address any points that
> get raised in general discussion).
>

The big problem is the release schedule of Python 2.5,  I've really 
wanted to get "something" along these lines going for Python 2.5, but 
I've not had the time to finish the PEP.  So, perhaps I'll tone down the 
request to a simple C-object with even less defined and put that out.

Frankly, I'm really looking for help from an avid Python-dev person who
may have an interest but perhaps not much experience with arrays.

-Travis




More information about the Python-Dev mailing list