[Numpy-discussion] fast take patch

Eric Firing efiring at hawaii.edu
Fri Apr 18 04:17:13 EDT 2008


Stefan, (or anyone else who might be interested)

Since you committed my fast putmask patch many months ago, I thought you 
might like to deal with my fast take patch.  Attached is the diff 
relative to 5043, ignoring whitespace.  (Yes, those pesky whitespace 
anomalies are still cropping up.)

The motivation for the patch is that in matplotlib color mapping, such 
as when displaying an image or pcolor plot, the time-limiting factor can 
be a single numpy operation of indexing into the color map. 
(http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg06482.html) 
It was being done with fancy indexing.  I changed that to use the take 
method, which sped it up by a factor of two, but I found that take 
itself is slower than it needs to be by a factor of 2-3.  As with 
putmask, the culprit is memmove, so I used the same strategy to 
substitute direct variable assignment when possible.

The patch includes tests for the take method.  I did not find any such 
pre-existing tests.

Thanks for taking a look.  Let me know what needs to be changed.

Eric
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fasttake.diff_5043uw
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080417/b0b5cafb/attachment.ksh>


More information about the NumPy-Discussion mailing list