Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03d97f2

Browse files
committed
Improved GC for python3.
1 parent d404e35 commit 03d97f2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/cbook.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ def __init__(self, cb):
365365
self._destroy_callbacks = []
366366
try:
367367
try:
368-
self.inst = ref(cb.im_self, self._destroy)
368+
if six.PY3:
369+
self.inst = ref(cb.__self__, self._destroy)
370+
else:
371+
self.inst = ref(cb.im_self, self._destroy)
369372
except TypeError:
370373
self.inst = None
371374
if six.PY3:
@@ -507,11 +510,13 @@ def connect(self, s, func):
507510
func will be called
508511
"""
509512
self._func_cid_map.setdefault(s, WeakKeyDictionary())
513+
# Note proxy not needed in python 3.
514+
# TODO rewrite this when support for python2.x gets dropped.
510515
proxy = _BoundMethodProxy(func)
511516
if proxy in self._func_cid_map[s]:
512517
return self._func_cid_map[s][proxy]
513518

514-
proxy.add_destroy_callback(self._remove_proxy) # Remove the proxy when it dies.
519+
proxy.add_destroy_callback(self._remove_proxy)
515520
self._cid += 1
516521
cid = self._cid
517522
self._func_cid_map[s][proxy] = cid

0 commit comments

Comments
 (0)