Commits

Alex Gaynor committed 3aa3dc9

use a dict instead of a list, this is WAY faster

Comments (0)

Files changed (1)

     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():