python - Weakref not getting deleted in REPL even after manual gc collection -


i seeing issue when executing below code in repl, after manually doing gc.collect() can still see weakref object. see below

 [67]: weakref import weakvaluedictionary  class a:     def __init__(self):         self.val = 1   = a()  w = weakvaluedictionary()  w['k1'] =  dict(w) out[72]: {'k1': <__main__.a @ 0x1e59e9b84a8>}  del   gc.collect() out[74]: 239  dict(w) out[75]: {'k1': <__main__.a @ 0x1e59e9b84a8>} 

ideally weakref should cleared once strong ref has been deleted , manual gc has been done, why still seeing this.

it looks like using ipython. described in the docs, ipython stores each output in numbered global variable. there global variable _72 holds reference dict(w) (the value output in out[72]), of course contains strong refence object formerly known a.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -