#14817: Inefficiency in copying PARI objects to the heap
---------------------------+------------------------------------------------
Reporter: pbruin | Owner: tbd
Type: enhancement | Status: new
Priority: minor | Milestone: sage-5.12
Component: performance | Keywords:
Work issues: | Report Upstream: N/A
Reviewers: | Authors: Peter Bruin
Merged in: | Dependencies:
Stopgaps: |
---------------------------+------------------------------------------------
When PARI objects are wrapped into Python objects, they are copied from
the PARI stack to a `malloc`'ed memory block. This is done by the
function `deepcopy_to_python_heap()` in `sage/libs/pari/gen.pyx`. To
determine how much memory to allocate, this function creates a dummy copy
on the stack and measures by how much the stack pointer goes down. This
is inefficient and can be improved by calling PARI's `gsizebyte()`
function, which does exactly what we want.
Also, copying the object to the `malloc`'ed block is done inelegantly by
temporarily changing the global variables `top`, `bot` and `avma` defining
the PARI stack. Again, there is a PARI function that does what we want:
`gcopy_avma()` does the same as `gcopy()`, but copies to a user-specified
address.
I am attaching a patch that replaces `deepcopy_to_python_heap()` by a
simpler and faster implementation. (It also deletes a comment that seems
to refer to code that no longer exists.)
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14817>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.