Ticket #4639: 4639-parent-memleak.patch

File 4639-parent-memleak.patch, 1.9 KB (added by robertwb, 15 months ago)
  • sage/structure/parent.pyx

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1229458970 28800
    # Node ID ce2185800a8419796e61e65c5338d5187cfd168a
    # Parent  89aa530400af7cb9d91a7f19749b6f2ec5bc60a0
    Fix memleak at ticket #4639 by removing old caching code.
    
    diff -r 89aa530400af -r ce2185800a84 sage/structure/parent.pyx
    a b  
    115115        return True 
    116116 
    117117 
    118 cdef object all_parents = [] #weakref.WeakKeyDictionary() 
    119  
    120118 
    121119cdef class Parent(category_object.CategoryObject): 
    122120    """ 
     
    151149        self._initial_coerce_list = [] 
    152150        self._initial_action_list = [] 
    153151        self._initial_convert_list = [] 
    154         all_parents.append(self) 
    155 #        try: 
    156 #            all_parents[self] = True # this is a weak reference 
    157 #        except: 
    158 #            print "couldn't weakref", type(self) 
    159152         
    160153    cdef int init_coerce(self, bint warn=True) except -1: 
    161154        if self._coerce_from_hash is None: 
     
    279272            mor = <map.Map>self.convert_map_from(R) 
    280273             
    281274        if mor is not None: 
    282             try: 
    283                 if no_extra_args: 
    284                     return mor._call_(x) 
    285                 else: 
    286                     return mor._call_with_args(x, args, kwds) 
    287             except TypeError: 
    288                 self._convert_from_hash.pop(mor.domain(), None) 
    289                 for i from 0 <= i < len(self._convert_from_list): 
    290                     if self._convert_from_list[i] is mor: 
    291                         del self._convert_from_list[i] 
    292                         break 
    293                 raise 
     275            if no_extra_args: 
     276                return mor._call_(x) 
     277            else: 
     278                return mor._call_with_args(x, args, kwds) 
    294279             
    295280        raise TypeError, "No conversion defined from %s to %s"%(R, self) 
    296281