Author: Lukas Diekmann <lukas.diekm...@uni-duesseldorf.de> Branch: set-strategies Changeset: r51224:b1a065c4225d Date: 2012-01-11 14:40 +0100 http://bitbucket.org/pypy/pypy/changeset/b1a065c4225d/
Log: (cfbolz, l.diekmann) implemented listview_str on 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".split() + popitem listview_str".split() def make_method(method): def f(self, *args): @@ -148,6 +148,9 @@ w_dict.strategy = strategy w_dict.dstorage = storage + def listview_str(self, w_dict): + return None + class EmptyDictStrategy(DictStrategy): @@ -457,6 +460,9 @@ assert key is not None return self.unerase(w_dict.dstorage).get(key, None) + def listview_str(self, w_dict): + return self.unerase(w_dict.dstorage).keys() + def iter(self, w_dict): return StrIteratorImplementation(self.space, self, w_dict) @@ -676,6 +682,7 @@ return space.newlist(w_self.items()) def dict_keys__DictMulti(space, w_self): + #XXX add fastpath for strategies here return space.newlist(w_self.keys()) def dict_values__DictMulti(space, w_self): 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 @@ -440,6 +440,8 @@ return w_obj.getitems_str() if isinstance(w_obj, W_SetObject): return w_obj.listview_str() + if isinstance(w_obj, W_DictMultiObject): + return w_obj.listview_str() return None def listview_int(self, w_obj): 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 @@ -142,6 +142,14 @@ assert space.eq_w(w_d.getitem_str("a"), space.w_None) assert space.eq_w(w_d.getitem_str("b"), space.w_None) + def test_listview_str_dict(self): + w = self.space.wrap + + w_d = self.space.newdict() + w_d.initialize_content([(w("a"), w(1)), (w("b"), w(2))]) + + assert self.space.listview_str(w_d) == ["a", "b"] + class AppTest_DictObject: def setup_class(cls): cls.w_on_pypy = cls.space.wrap("__pypy__" in sys.builtin_module_names) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit