[Numpy-discussion] Arrays of Python Values

Ian Mallett geometrian@gmail....
Fri Jul 23 03:16:41 CDT 2010


So working on the radiosity renderer:

The code now runs fast enough to generate the data required to draw that.
Now, I need to optimize the radiosity calculation, so that it will converge
in a reasonable amount of time.  Right now, the individual blocks
("patches") are stored as instances of Python classes in a list.

I'd heard that NumPy supports arrays of Python objects, so, I simply made an
array out of the list, which seemed ok.  Unfortunately, there is a custom
sorting operation that sorted the list of by an attribute of each class:

self.patches.sort( lambda x,y:cmp(x.residual_radiance,y.residual_radiance),
reverse=True )

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.

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?

Thanks again for the extremely valuable help,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100723/b06ce471/attachment.html 

More information about the NumPy-Discussion mailing list