Dear Paisa,

On Sep 26, 9:26 am, Robert Bradshaw <[EMAIL PROTECTED]>
wrote:
...
> For consistency, we would like the type of 3 < f to depend only on  
> the parent (e.g. type) of f. Otherwise things become too hard to  
> reason with. However, in your case you might want to do something like
>
> n_pi = RDF.pi()
>
> in which case things like 3<n_pi will be very fast.

Indeed:
sage: timeit('bool(3<pi)')
5 loops, best of 3: 30.3 ms per loop
sage: timeit('3<RR(pi)')  # conversion to bool not needed
625 loops, best of 3: 4.86 µs per loop
sage: timeit('3<RDF(pi)')
625 loops, best of 3: 4.28 µs per loop

Or, if you need the comparison very often, follow Robert's suggestion
to define your own constant:
sage: PI=RDF(pi)
sage: timeit('3<PI')  # conversion to bool isn't needed here
625 loops, best of 3: 1.59 µs per loop

Respectively in cython, you might cdef your constant PI.

But i wonder one thing: Why is the following so slow, compared with
using RR or RDF?
sage: timeit('3<float(pi)')
625 loops, best of 3: 523 µs per loop


Cheers
  Simon
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to