Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r58820:3aa3dc9af594
Date: 2012-11-10 14:17 -0800
http://bitbucket.org/pypy/pypy/changeset/3aa3dc9af594/
Log: use a dict instead of a list, this is WAY faster
diff --git a/pypy/rlib/rgc.py b/pypy/rlib/rgc.py
--- a/pypy/rlib/rgc.py
+++ b/pypy/rlib/rgc.py
@@ -313,21 +313,21 @@
return True
has_gcflag_extra._subopnum = 1
-_gcflag_extras = []
+_gcflag_extras = {}
def get_gcflag_extra(gcref):
"NOT_RPYTHON"
assert gcref # not NULL!
- return gcref in _gcflag_extras # XXX slow
+ return gcref in _gcflag_extras
get_gcflag_extra._subopnum = 2
def toggle_gcflag_extra(gcref):
"NOT_RPYTHON"
assert gcref # not NULL!
try:
- _gcflag_extras.remove(gcref) # XXX slow
- except ValueError:
- _gcflag_extras.append(gcref)
+ del _gcflag_extras[gcref]
+ except KeyError:
+ _gcflag_extras[gcref] = None
toggle_gcflag_extra._subopnum = 3
def assert_no_more_gcflags():
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit