Re: A surprising case of cyclic trash

April 5, 2000
5:19 a.m.
An even simpler example:
import sys d = {} print sys.getrefcount(d) 2 exec("def f(): pass\n") in d print sys.getrefcount(d) 3 d.clear() print sys.getrefcount(d) 2
exec adds the function to the dictionary. The function references the dictionary through globals. Neil -- "If elected mayor, my first act will be to kill the whole lot of you, and burn your town to cinders!" -- Groundskeeper Willie
9211
Age (days ago)
9211
Last active (days ago)
0 comments
1 participants
participants (1)
-
Neil Schemenauer