Ticket #13741: trac13741_pari_dealloc.patch

File trac13741_pari_dealloc.patch, 1.4 KB (added by Simon King, 10 years ago)

Pari deallocation in a more Cythonic way

  • sage/all.py

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1354288095 -3600
    # Node ID af0caf3462f6f7873f0f75935bee4d5ba7c46924
    # Parent  23061edf00176562a9d754123cfebbb8e3f631d3
    #13741: Use the Cythonic way of deallocating the unique Pari instance
    
    diff --git a/sage/all.py b/sage/all.py
    a b  
    233233    import sage.libs.flint.flint
    234234    sage.libs.flint.flint.free_flint_stack()
    235235
    236     pari._unsafe_deallocate_pari_stack()
    237    
    238236    # stop the twisted reactor
    239237    try:
    240238       from twisted.internet import reactor
  • sage/libs/pari/gen.pyx

    diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
    a b  
    91979197        pariOut.flush = sage_flush
    91989198        sig_off()
    91999199
    9200     def _unsafe_deallocate_pari_stack(self):
     9200    def __dealloc__(self):
     9201        """
     9202        Deallocation of the Pari instance.
     9203
     9204        NOTE:
     9205
     9206        Usually this deallocation happens only when Sage quits.
     9207        We do not provide a direct test, since usually there
     9208        is only one Pari instance, and when artificially creating
     9209        another instance, C-data are shared.
     9210
     9211        The fact that Sage does not crash when quitting is an
     9212        indirect doctest. See the discussion at :trac:`13741`.
     9213
     9214        """
    92019215        if bot:
    92029216            sage_free(<void*>bot)
    92039217        global top, bot