[Numpy-discussion] Questions about the array interface.

Travis Oliphant oliphant at ee.byu.edu
Thu Apr 7 15:47:04 EDT 2005

Scott Gilbert wrote:

>I agree, we need a road map of some sort.  It could be multiple PEPs
>depending, but it should include most of the following:
>    - Get the bytes object submitted.  There are only a few small
>      things in PEP 296 that should be changed.

>      - I'm not particularly interested in implementing the new bytes
>        literal and other features discussed in PEP 332, but it is
>        related to this topic.  (The proposal is for b"xxxxxx" to be a
>        bytes literal.)  We should make note that while this is not
>        part of the numpy roadmap, nothing prohibits that from being
>        implemented by another user.
>    - Add an ndarray module.  This module will contain the ndarray
>      object as well as a superset of your helper functions.  I
>      think implementing it in pure Python on top of the bytes
>      object is the right course.  It's partly for documentation.
>    - Add an include file to make this protocol easily accessible
>      from C.  It's not much code, and the entire thing could be
>      done with inline/static functions in the .h file.  It would
>      be nice if this went into Python too, but not strictly
>      required.
I put these together at #1

>    - Add the array protocol attributes to the existing array
>      object.

>    - Flesh out the "locked buffer" stuff in PEP 298.  Add support
>      for locking the buffer to the existing array object, the
>      bytes object, the mmap object, and anything else (string?)
>      that doesn't meet too much resistance.

>    - Fix the existing buffer object to regrab it's pointer
>      every time it's needed.  Could also add support to use
>      the "locked buffer" interface where possible.  I gather
>      that you are using this particular object in scipy.base
>      (is that true??).  Several shortcomings of it could be
>      easily fixed at the Python level, but I don't feel
>      strongly that this would have to be done...  Then again
>      it isn't much work.

I can't think of anything you've missed.

I'm very supportive of this, but I have to finish scipy.base first.   I 
think Perry is supportive as well.  I know he's been playing catch-up in 
the reading.   I'm not sure of Todd's opinion.   I suspect he would 
welcome these changes to Python.

My preference order is

1) the ndarray module and ndarray.h  header with these interface 
definitions and methods. 
2) Add array interface attributes to array module
3) Flesh out locked buffer API
4) Bytes object (with Pickling support)
5) Fix current buffer object.


More information about the NumPy-Discussion mailing list