[Numpy-discussion] Arrays of Python Values

Pauli Virtanen pav at iki.fi
Fri Jul 23 04:58:39 EDT 2010


Fri, 23 Jul 2010 01:16:41 -0700, Ian Mallett wrote:
[clip]
> Because I've never used arrays of Python objects (and Googling didn't
> turn up any examples), I'm stuck on how to sort the corresponding array
> in NumPy in the same way.

I doubt you will gain any speed by switching from Python lists to Numpy 
arrays containing Python objects.

> Of course, perhaps I'm just trying something that's absolutely
> impossible, or there's an obviously better way.  I get the feeling that
> having no Python objects in the NumPy array would speed things up even
> more, but I couldn't figure out how I'd handle the different attributes
> (or specifically, how to keep them together during a sort).
> 
> What're my options?

One option could be to use structured arrays to store the data, instead 
of Python objects.

-- 
Pauli Virtanen




More information about the NumPy-Discussion mailing list