On Sep 26, 2008, at 12:44 AM, Simon King wrote:
> Sorry for answering to myself:
>
> On Sep 26, 9:42 am, Simon King <[EMAIL PROTECTED]> wrote:
>> 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
>
> Probably since "3" is not a float yet:
>
> sage: PI=float(pi)
> sage: timeit('3<PI')
> 625 loops, best of 3: 527 µs per loop
> sage: timeit('float(3)<PI')
> 625 loops, best of 3: 837 ns per loop
Since 3 is an Element but float(pi) is not, it tries to turn 3 into
an Integer for comparison, fails, then turns 3 into a float. Between
two Elements it is able to cache which direction to go, and then use
that every time thereafter.
- Robert
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---