|
From: Christoph G. <cg...@uc...> - 2011-02-09 00:39:58
|
On 2/5/2011 1:02 PM, Eric Firing wrote: > On 02/04/2011 02:03 PM, Christoph Gohlke wrote: > [...] >> >> How about these changes to color.py (attached). This avoids copies, uses >> in-place operations, and calculates single precision when normalizing >> small integer and float32 arrays. Similar could be done for LogNorm. Do >> masked arrays support in-place operations? >> >> Christoph > > Christoph, > > Thank you. > > Done (with slight modifications) in 8946 (trunk). > > I was surprised by the speedup in normalizing large arrays when using > float32 versus float64. A factor of 10 on my machine with (1000,1000), > timed with ipython %timeit. Because of the way %timeit does multiple > tests, I suspect it may exaggerate cache effects. > > Eric Please consider the attached patch for the _image.frombyte function. It avoids temporary copies in case of non-contiguous input arrays. Copying a 1024x1024 slice out of a contiguous 4096x4096 RGBA or RGB array is about 7x faster (a common case for zooming/panning). Copying contiguous RGB input arrays is ~2x faster. Tested on win32-py2.7. Christoph |