[Numpy-discussion] ragged array implimentation
aarchiba at physics.mcgill.ca
Mon Mar 7 17:25:19 EST 2011
On 7 March 2011 15:29, Christopher Barker <Chris.Barker at noaa.gov> wrote:
> On 3/7/11 11:18 AM, Francesc Alted wrote:
>> but, instead of returning a numpy array of 'object' elements, plain
>> python lists are returned instead.
> which gives you the append option -- I can see how that would be
> usefull. Though I'd kind of like to have numpy ufunc/broadcasting
> performance. i.e.:
> vlarray * some_constant
> Be fast, and work out of the box!
How about this? Represent them as object arrays (or lists) of
variable-length 1d arrays. But create the 1d arrays by building one
large 1d array with them all concatenated, then taking slices. Keep
the single array around, perhaps in an attribute of the object array;
after all, most of the numpy operations are elementwise and don't care
about array structure. You'd want to be able to convert between a flat
array plus length vector and object array in some reasonably efficient
manner, and I think this allows that.
More information about the NumPy-Discussion