Skip to content

Commit

Permalink
Use the trashcan for Gen
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Feb 20, 2019
1 parent 725a22c commit 78e6dcf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions cypari2/gen.pxd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cimport cython
from cpython.object cimport PyObject
from .types cimport GEN, pari_sp

Expand Down
1 change: 1 addition & 0 deletions cypari2/gen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ cdef extern from *:
GEN new_nfeltup(GEN nf, GEN x, GEN zknf)


@cython.trashcan(True)
cdef class Gen(Gen_base):
"""
Wrapper for a PARI ``GEN`` with memory management.
Expand Down
9 changes: 9 additions & 0 deletions cypari2/pari_instance.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ Reset default precision for the following tests:
>>> pari.set_real_precision_bits(53)
Test the trashcan mechanism (without the trashcan, this would cause
a stack overflow):
>>> pari.allocatemem(2**27, silent=True)
>>> L = [pari(i) for i in range(2**20)]
>>> x = pari.Pi()
>>> del L
>>> del x
Test that interrupts work properly:
>>> pari.allocatemem(8000000, 2**29)
Expand Down

0 comments on commit 78e6dcf

Please sign in to comment.