#7251: Allow for Integer(3, parent = MyParent)
--------------------------------+-------------------------------------------
   Reporter:  nthiery           |       Owner:  nthiery                
       Type:  enhancement       |      Status:  needs_review           
   Priority:  major             |   Milestone:  sage-4.2               
  Component:  basic arithmetic  |    Keywords:  Integer, IntegerWrapper
Work_issues:                    |      Author:  Nicolas M. ThiƩry      
   Reviewer:                    |      Merged:                         
--------------------------------+-------------------------------------------
Changes (by nthiery):

 * cc: robertwb (added)
  * status:  new => needs_review


Comment:

 Replying to [comment:8 robertwb]:
 > I should explain this a bit more--typically there shouldn't be any
 issues doing this with Cython classes. With Integers what we do is hijack
 the allocation/deallocation function slots with our own custom functions
 that stick already allocated Integers (with initialized parent and mpz_t
 fields) into a pool on "deallocation" and then pull them out whenever a
 new one is needed. Because Integers are so common, this is actually a
 significant savings, but does cause issues with subclassing from Python.
 >
 > IntegerWrapper is OK because it statically sets its alloc/dealloc
 methods to the *original* Integer alloc/dealloc methods (before we
 manually swap them out for ours).

 Thanks for the explanations! I have added them to the documentation of
 IntegerWrapper.

 The latest patch also just modifies IntegerWrapper, without touching
 Integer.

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