Author: Lukas Diekmann <[email protected]>
Branch: set-strategies
Changeset: r49161:28e84214560e
Date: 2011-05-17 13:46 +0200
http://bitbucket.org/pypy/pypy/changeset/28e84214560e/
Log: EmptySet.add() switches to correct strategy now
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -212,8 +212,13 @@
return clone
def add(self, w_set, w_key):
- #XXX switch to correct strategy later
- w_set.switch_to_object_strategy(self.space)
+ from pypy.objspace.std.intobject import W_IntObject
+ if type(w_key) is W_IntObject:
+ w_set.strategy = self.space.fromcache(IntegerSetStrategy)
+ else:
+ w_set.strategy = self.space.fromcache(ObjectSetStrategy)
+
+ w_set.sstorage = w_set.strategy.get_empty_storage()
w_set.add(w_key)
def delitem(self, w_set, w_item):
@@ -551,6 +556,9 @@
cast_to_void_star = staticmethod(cast_to_void_star)
cast_from_void_star = staticmethod(cast_from_void_star)
+ def get_empty_storage(self):
+ return self.cast_to_void_star({})
+
def get_empty_dict(self):
return {}
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit