#12149: float('nan')>1 crashes Sage.
--------------------------------+-------------------------------------------
   Reporter:  was               |          Owner:  AlexGhitza   
       Type:  defect            |         Status:  needs_review 
   Priority:  critical          |      Milestone:  sage-4.8     
  Component:  basic arithmetic  |       Keywords:               
Work_issues:                    |       Upstream:  N/A          
   Reviewer:                    |         Author:  William Stein
     Merged:                    |   Dependencies:               
--------------------------------+-------------------------------------------

Comment(by SimonKing):

 Here are better timings (I hope):

 Unpatched 4.8.alpha3:
 {{{
 sage: a = 1
 sage: b = float(1)
 sage: c = float(2.5)
 sage: timeit("a==b",number=10^5)
 100000 loops, best of 3: 320 ns per loop
 sage: timeit("a==c",number=10^5)
 100000 loops, best of 3: 323 ns per loop
 }}}

 With William's patch:
 {{{
 sage: a = 1
 sage: b = float(1)
 sage: c = float(2.5)
 sage: d = float('nan')
 sage: timeit("a==b",number=10^5)
 100000 loops, best of 3: 336 ns per loop
 sage: timeit("a==c",number=10^5)
 100000 loops, best of 3: 333 ns per loop
 sage: timeit("a==d",number=10^5)
 100000 loops, best of 3: 281 ns per loop
 }}}

 With the sig_on/off alternative:
 {{{
 sage: a = 1
 sage: b = float(1)
 sage: c = float(2.5)
 sage: d = float('nan')
 sage: timeit("a==b",number=10^5)
 100000 loops, best of 3: 369 ns per loop
 sage: timeit("a==c",number=10^5)
 100000 loops, best of 3: 369 ns per loop
 sage: timeit("a==c",number=10^5)
 100000 loops, best of 3: 369 ns per loop
 sage: timeit("a==d",number=10^5)
 100000 loops, best of 3: 3.92 µs per loop
 }}}

 I don't know the standard deviation of these timings (does "timeit" offer
 such statistics?) - when repeating the tests, I sometimes got 380 ns, not
 369 ns.

 But the timings seem to suggest that William's patch is 10% faster in the
 "number" case and is a lot faster in the "not a number" case.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12149#comment:16>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
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-trac?hl=en.

Reply via email to