#7251: Allow for Integer(3, parent = MyParent)
--------------------------------+-------------------------------------------
Reporter: nthiery | Owner: nthiery
Type: enhancement | Status: new
Priority: major | Milestone: sage-4.2
Component: basic arithmetic | Keywords: Integer, IntegerWrapper
Work_issues: | Author: Nicolas M. ThiƩry
Reviewer: | Merged:
--------------------------------+-------------------------------------------
Comment(by robertwb):
Yes, you should just use the wrapper (at least for now).
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).
It's all a bit messy, and I've been wanting to redo it for a while
(extending it to a cleaner and more generic framework that can be used
elsewhere) but I have much higher priority stuff (like a thesis) to be
doing.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7251#comment:8>
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
-~----------~----~----~----~------~----~------~--~---