Author: Armin Rigo <[email protected]>
Branch: keys_with_hash
Changeset: r79325:8ca42034ab3f
Date: 2015-08-31 16:47 +0200
http://bitbucket.org/pypy/pypy/changeset/8ca42034ab3f/
Log: Identified a difference of performance with CPython: at least in
RPython code, there are places where we should reuse the hash of a
dict key instead of recomputing it
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
@@ -965,6 +965,9 @@
other_dict = self.unerase(w_other.sstorage)
result_dict = self.get_empty_dict()
for key in iterator:
+ # xxx performance issue when compared to CPython: the next
+ # two lines will recompute twice the hash of 'key', whereas
+ # CPython reuses the hash from 'iterator' in both cases.
if key not in other_dict:
result_dict[key] = None
return self.erase(result_dict)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit