Author: Lukas Diekmann <[email protected]>
Branch: set-strategies
Changeset: r51225:19aec63fdbfe
Date: 2012-01-11 14:44 +0100
http://bitbucket.org/pypy/pypy/changeset/19aec63fdbfe/
Log: (cfbolz, l.diekmann): implemented listview_int for dicts
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
@@ -91,7 +91,7 @@
getitem_str delitem length \
clear keys values \
items iter setdefault \
- popitem listview_str".split()
+ popitem listview_str listview_int".split()
def make_method(method):
def f(self, *args):
@@ -151,6 +151,8 @@
def listview_str(self, w_dict):
return None
+ def listview_int(self, w_dict):
+ return None
class EmptyDictStrategy(DictStrategy):
@@ -528,6 +530,9 @@
def iter(self, w_dict):
return IntIteratorImplementation(self.space, self, w_dict)
+ def listview_int(self, w_dict):
+ return self.unerase(w_dict.dstorage).keys()
+
class IntIteratorImplementation(_WrappedIteratorMixin, IteratorImplementation):
pass
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -449,6 +449,8 @@
return w_obj.getitems_int()
if isinstance(w_obj, W_SetObject):
return w_obj.listview_int()
+ if isinstance(w_obj, W_DictMultiObject):
+ return w_obj.listview_int()
return None
def sliceindices(self, w_slice, w_length):
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -150,6 +150,13 @@
assert self.space.listview_str(w_d) == ["a", "b"]
+ def test_listview_int_dict(self):
+ w = self.space.wrap
+ w_d = self.space.newdict()
+ w_d.initialize_content([(w(1), w("a")), (w(2), w("b"))])
+
+ assert self.space.listview_int(w_d) == [1, 2]
+
class AppTest_DictObject:
def setup_class(cls):
cls.w_on_pypy = cls.space.wrap("__pypy__" in sys.builtin_module_names)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit