Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
15928944
Commit
15928944
authored
Jun 24, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try again to make weakref1 more robust
parent
59479580
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
15 deletions
+6
-15
test/tests/weakref1.py
test/tests/weakref1.py
+6
-15
No files found.
test/tests/weakref1.py
View file @
15928944
import
weakref
import
gc
num_destroyed
=
0
def
cb
(
wr
):
print
"object was destroyed"
,
wr
()
global
num_destroyed
num_destroyed
+=
1
def
doStuff
():
def
meth
():
...
...
@@ -11,18 +13,7 @@ def doStuff():
wr
=
weakref
.
ref
(
meth
,
cb
)
return
wr
def
fact
(
n
):
if
n
<=
1
:
return
n
return
n
*
fact
(
n
-
1
)
w
=
doStuff
()
fact
(
10
)
# try to clear some memory
def
recurse
(
f
,
n
):
if
n
:
return
recurse
(
f
,
n
-
1
)
return
f
()
recurse
(
gc
.
collect
,
50
)
l
=
[
doStuff
()
for
i
in
xrange
(
5
)]
gc
.
collect
()
assert
num_destroyed
>=
1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment