[Numpy-discussion] Notes from meeting with Guido regarding inclusion of array package in Python core

Travis Oliphant oliphant at ee.byu.edu
Fri Mar 11 01:07:05 CST 2005


>> Sorry I wasn't clear. The present Helper functions check to see if 
>> the sequence is a list, and use list specific code if it is, 
>> otherwise, it falls back the sequence protocol, which is why it's 
>> slow for Numeric arrays. I'm proposing that if the input is an array, 
>> it will then use array-specific code (perhaps 
>> PyArray_ContiguousFromObject, then accessing *data directly)
>
>
> If the über-buffer object (item 1c in Perry's notes) gets implemented 
> in the standard library, then the Helper functions could test 
> PyUberBuffer_Check() (or perhaps test for the presence of the extra 
> Numeric information, whatever), dispatch on the typecode, and iterate 
> through the data as appropriate. wx's C code doesn't need to know 
> about the Numeric array struct (and thus doesn't need to include any 
> headers), it just needs to know how to interpret the metadata provided 
> by the über-buffer.
>
> What's more, other packages could nearly seamlessly provide data in 
> the same way. For example, suppose your wx function plopped a pixel 
> image onto a canvas. It could take one of these buffers as the pixel 
> source. PIL could be a source. A Numeric array could be a source. A 
> string could be a source. A Quartz CGBitmapContext could be a source. 
> As long as each could be adapted to include the conventional metadata, 
> they could all be source for the wx function, and none of the packages 
> need to know about each other much less be compiled against one 
> another or depend on their existence at runtime. I say "nearly 
> seamlessly" only because there might be an inevitable adaptation layer 
> that adds or modifies the metadata.
>
> The buffer approach seems like the most Pythonic way to go. It 
> encourages loose coupling and flexibility. It also encourages object 
> adaptation, a la PyProtocols[1], which I like to push now and again.


I really, really like this direction.   Todd's memoryobject in numarray 
should be merged with the buffer object in Python to be this new  buffer 
type and the appropriate meta-data added.  We should then, start 
encouraging this sort of buffer-mediated duck-typing for all raw 
memory-like objects and the buffer protocol expanded to encourage the 
specification of metadata (or classes of metadata).

We should do a lot more of this....(a la namespaces...)

-Travis





More information about the Numpy-discussion mailing list