#10314: speed up comparison of Integers and native Python numeric types
--------------------------------+-------------------------------------------
   Reporter:  roed              |       Owner:  AlexGhitza
       Type:  enhancement       |      Status:  needs_work
   Priority:  major             |   Milestone:  sage-4.6.1
  Component:  basic arithmetic  |    Keywords:            
     Author:  David Roe         |    Upstream:  N/A       
   Reviewer:                    |      Merged:            
Work_issues:                    |  
--------------------------------+-------------------------------------------
Changes (by was):

  * status:  needs_review => needs_work


Comment:

 Here's a major bug this introduces:
 {{{
         822                 elif PyFloat_CheckExact(left):
         823                     c = -mpz_cmp_d((<Integer>right).value,
 PyFloat_AsDouble(right))
 }}}

 Note that you're comparing right to itself.

 Another thought I had is that the tmp mpz could be put at the module scope
 and never mpz_clear'd.  This means a tiny leak, but it removes the
 mpz_init and mpz_clear completely, and replaces them with a single
 mpz_set, which could be a big savings in time, since memory allocation is
 so expensive.

 In fact, looking in integer.pyx I see this near the top:
 {{{
 cdef mpz_t mpz_tmp
 mpz_init(mpz_tmp)
 }}}
 so just use that mpz_tmp that is sitting there, instead of making another
 one.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10314#comment:2>
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