On Sat, Jul 21, 2007 at 08:51:19AM -1000, Eric Firing wrote:
> John Hunter wrote:
> [...]
> > functions or array functions here, eg math.sqrt vs numpy.sqrt?  Also,
> > a few of your symbols clash with python builtins (min, max, abs) which
> > is best avoided.  Finally, how would you feel about allowing these
> > symbols in the module namespace, but w/o the import * semantics, eg,
> > for these symbols we do
> > 
> > from mpl.math import exp, sin, pi, sin, cos, ...
> 
> There is no point in this; better to import these directly from numpy, 
> if that is what is wanted.

oops... missed that detail.  Yes of course in we are explicitly importing
a name be explicit about where it is coming from.

>  But sometimes we actually want a masked 
> array version.
> 
> For many of these things there are up to 5 different possible sources:
> 
> (builtin, if not math or cmath)
> math
> cmath
> numpy
> numpy.ma
> maskedarray
> 
> Sometimes functions from the different sources do the same thing, but 
> usually at different speeds, and sometimes they don't do the same thing 
> at all.  In most cases we want, or at least can manage with, either the 
> numpy version or one of the masked versions, presently accessed via 
> numpy.numerix.npyma, which is imported via
> 
> import numpy.numerix.npyma as ma
> 
> The recently introduced policy of simply being very explicit *does* 
> work;  when looking at an expression one always knows which functions 
> are being invoked.  Like Paul, I recoil a bit at the clunky appearance, 
> but apparently unlike Paul, I find the explicitness helpful--especially 
> since I am very conscious of the need to use masked versions in some places.

I'm surprised by the poor performance of numpy scalars reported elsewhere.

Given that one is forced to be explicit about the source of the function
and given that there is no good solution, I guess using numpy.sin, etc.
is best.

Here's some timings of various possibilities on my machine:

 0.20  import from math outside the function call
 0.22  use math.sin and math.pi inside the function call
 0.53  import from math inside the function call
 0.67  import from numpy outside the function call
 0.70  use numpy.sin and numpy.pi inside the function call
 1.14  import from numpy inside the function call

- Paul

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to