Commit f456378f authored by Kevin Modzelewski's avatar Kevin Modzelewski

Try to make weakref4 more robust

parent 087316e2
...@@ -7,14 +7,13 @@ def doStuff(): ...@@ -7,14 +7,13 @@ def doStuff():
wr = weakref.ref(meth) wr = weakref.ref(meth)
return wr return wr
def fact(n): def recurse(f, n):
if n <= 1: if n:
return n return recurse(f, n-1)
return n * fact(n-1) return f()
w = doStuff() w = recurse(doStuff, 100)
print fact(10) # try to clear some memory
# Try creating a large object to make sure we can handle them: # Try creating a large object to make sure we can handle them:
def f(): def f():
...@@ -24,7 +23,7 @@ def f(): ...@@ -24,7 +23,7 @@ def f():
return weakref.ref(C) return weakref.ref(C)
r = f() r = recurse(f, 100)
import gc import gc
gc.collect() gc.collect()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment