#4286: [with patch, needs review] minor improvements to old integer code
------------------------------+---------------------------------------------
 Reporter:  robertwb          |        Owner:  somebody
     Type:  defect            |       Status:  new     
 Priority:  major             |    Milestone:  sage-3.2
Component:  basic arithmetic  |   Resolution:          
 Keywords:                    |  
------------------------------+---------------------------------------------
Changes (by GeorgSWeber):

  * milestone:  => sage-3.2

Comment:

 Tired as I am, I only write down some remarks from "pure reading":

 1. The (new) lines 3636 and 3682 ("return v[0]") should perhaps be:

    return as_Integer(v[0])

 i.e. with the explicit (eventual) conversion of v[0] to a Sage integer.
 Probably that is done by the compiler implicitly. But anyway, the code
 would display even more visibly its intention what it is doing.

 2. I'm unsure whether the macro "PY_TYPE_CHECK" is allowed to be used
 inside _sig_on / _sig_off. And even if it is for the time being, a future
 change of that macro using some more pythonics might bombastically break
 the new code this patch brings --- at runtime. (It's implicitly used in
 lines 3639, 3641, 3685, 3687 inside "as_Integer".)

 3. The line 3523 ("if mpz_cmp_ui(m.value, 1) == 0:"). If I was a puricist,
 I'd say it should be replaced by the four lines:

    _sig_on
    r = mpz_cmp_ui(m.value, 1)
    _sig_off
    if r == 0:

 Thus this "external" function call to GMP is wrapped by _sig_on/_sig_off,
 too.
 (The variable r is destroyed in the very next line anyway.)

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4286#comment:1>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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