On Feb 28, 2009, at 11:17 AM, Jason Grout wrote:

> How come srange is so slow compared to numpy arange?

Because no one has ever optimized this case yet. I bet all the  
additions are being done as Python floats in srange, but as c doubles  
in numpy. Note that even (on my machine)

sage: %timeit srange(0, 100, universe=float)
10000 loops, best of 3: 53.1 µs per loop
sage: %timeit srange(0, 100, universe=ZZ)
10000 loops, best of 3: 39.6 µs per loop

> ----------------------------------------------------------------------
> | Sage Version 3.4.alpha0, Release Date: 2009-02-24                  |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> sage: import numpy
> sage: timeit('srange(1.5r,4r,universe=float,check=False)')
> 625 loops, best of 3: 40 µs per loop
> sage: timeit('list(numpy.arange(1.5r,4r))')
> 625 loops, best of 3: 7.76 µs per loop
> sage:
> srange(1.5r,4r,universe=float,check=False)==list(numpy.arange(1.5r, 
> 4r))
> True
>
>
> Is there a Sage command for constructing a list of python floats that
> gets equivalent speed as the numpy arange command?

Not yet :).

- Robert



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to