[pypy-svn] r55303 - pypy/dist/pypy/objspace/std
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue May 27 16:40:40 CEST 2008
Author: cfbolz
Date: Tue May 27 16:40:36 2008
New Revision: 55303
Modified:
pypy/dist/pypy/objspace/std/dicttype.py
Log:
fix complexity of popitem, which should be faster than O(len(dict))
Modified: pypy/dist/pypy/objspace/std/dicttype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dicttype.py (original)
+++ pypy/dist/pypy/objspace/std/dicttype.py Tue May 27 16:40:36 2008
@@ -80,10 +80,10 @@
update1(d, kwargs)
def popitem(d):
- k = dict.keys(d)
- if not k:
+ for k in dict.iterkeys(d):
+ break
+ else:
raise KeyError("popitem(): dictionary is empty")
- k = k[0]
v = dict.__getitem__(d, k)
dict.__delitem__(d, k)
return k, v
More information about the Pypy-commit
mailing list