[Python-Dev] PEP: Adding data-type objects to Python (original) (raw)

Travis Oliphant oliphant.travis at ieee.org
Thu Nov 2 01:58:01 CET 2006


Alexander Belopolsky wrote:

Travis Oliphant <oliphant.travis ieee.org> writes:

b = buffer(array('d', [1,2,3])) there is not much that I can do with b. For example, if I want to pass it to numpy, I will have to provide the type and shape information myself: numpy.ndarray(shape=(3,), dtype=float, buffer=b) array([ 1., 2., 3.]) With the extended buffer protocol, I should be able to do numpy.array(b)

or just

numpy.array(array.array('d',[1,2,3]))

and leave-out the buffer object all together.

So let's start by solving this problem and limit it to data that can be found in a standard library array. This way we can postpone the discussion of shapes, strides and nested structs.

Don't lump those ideas together. Shapes and strides are necessary for N-dimensional array's (it's essentially what defines the N-dimensional array). I really don't want to sacrifice those in the extended buffer protocol. If you want to separate them into different functions then that is a possibility.

If we manage to agree on the standard way to pass primitive type information, it will be a big achievement and immediately useful because simple arrays are already in the standard library.

We could start there, I suppose. Especially if it helps us all get on the same page. But, we already see the applications beyond this simple case so I would like to have at least an "eye" for the more difficult case which we already have a working solution for in the "array interface"

-Travis



More information about the Python-Dev mailing list