#11868: PARI library interface broken by design
-----------------------------------+------------------------------
Reporter: jdemeyer | Owner: was
Type: defect | Status: needs_work
Priority: major | Milestone: sage-5.13
Component: interfaces | Resolution:
Keywords: t0GEN t1GEN gen | Merged in:
Authors: Peter Bruin | Reviewers: Jeroen Demeyer
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-----------------------------------+------------------------------
Comment (by jdemeyer):
I have also been thinking about using a `with` statement:
{{{
cdef GEN r
with to_GEN(s) as t0:
pari_catch_sig_on
r = gwhatever(t0)
pari_catch_sig_off
return new_gen(r) # Clears stack but doesn't call pari_catch_sig_off()
}}}
Then `to_GEN` would be something like
{{{
cimport cython
@cython.final
cdef class to_GEN:
cdef gen x
def __init__(to_GEN self, s):
self.x = s._pari_()
cdef inline GEN __enter__(to_GEN self):
return self.x.g
cdef inline int __exit__(to_GEN self, typ, value, traceback):
return 0
}}}
This looks more complicated, but it has the added advantage that the `gen`
object for `s` is hidden inside the `to_GEN` class and that the `gen` `x`
is kept alive for just the right amount of time. This opens a possibility
(not on this ticket) to make `deepcopy_to_python_heap()` lazy, such that
it only activates when the PARI stack is cleared.
--
Ticket URL: <http://trac.sagemath.org/ticket/11868#comment:19>
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.