Skip to content

Commit a93e17c

Browse files
jdemeyerMatthias Koeppe
authored andcommitted
Use the trashcan for Gen
1 parent 2714441 commit a93e17c

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

cypari2/gen.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cimport cython
12
from cpython.object cimport PyObject
23
from .types cimport GEN, pari_sp
34

cypari2/gen.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ cdef extern from *:
141141
GEN old_nfbasis(GEN x, GEN * y, GEN p)
142142

143143

144+
@cython.trashcan(True)
144145
cdef class Gen(Gen_base):
145146
"""
146147
Wrapper for a PARI ``GEN`` with memory management.

cypari2/pari_instance.pyx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ Reset default precision for the following tests:
243243
244244
>>> pari.set_real_precision_bits(53)
245245
246+
Test the trashcan mechanism (without the trashcan, this would cause
247+
a stack overflow):
248+
249+
>>> pari.allocatemem(2**27, silent=True)
250+
>>> L = [pari(i) for i in range(2**20)]
251+
>>> x = pari.Pi()
252+
>>> del L
253+
>>> del x
254+
246255
Test that interrupts work properly:
247256
248257
>>> pari.allocatemem(8000000, 2**29)

0 commit comments

Comments
 (0)