[pypy-commit] pypy keys_with_hash: Identified a difference of performance with CPython: at least in
arigo
noreply at buildbot.pypy.org
Mon Aug 31 19:05:47 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
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)
More information about the pypy-commit
mailing list