Author: Lukas Diekmann <[email protected]>
Branch: dict-strategies
Changeset: r44459:edaa171f9274
Date: 2011-04-15 15:20 +0200
http://bitbucket.org/pypy/pypy/changeset/edaa171f9274/
Log: refactored clear-method of dict strategies and moved it to base
strategy class (DictStrategy)
diff --git a/pypy/objspace/std/dictmultiobject.py
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -166,6 +166,11 @@
key = OPTIMIZED_BUILTINS[i]
return self.getitem_str(w_dict, key)
+ def clear(self, w_dict):
+ strategy = self.space.fromcache(EmptyDictStrategy)
+ storage = strategy.get_empty_storage()
+ w_dict.strategy = strategy
+ w_dict.dstorage = storage
# _________________________________________________________________
# implementation methods
@@ -314,10 +319,6 @@
return [self.space.newtuple([w_key, w_val])
for w_key, w_val in
self.cast_from_void_star(w_dict.dstorage).iteritems()]
- def clear(self, w_dict):
- #XXX switch to empty
- self.cast_from_void_star(w_dict.dstorage).clear()
-
def popitem(self, w_dict):
return self.cast_from_void_star(w_dict.dstorage).popitem()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit