Author: Armin Rigo <[email protected]>
Branch:
Changeset: r74878:e56dfa6f9309
Date: 2014-12-10 15:32 +0000
http://bitbucket.org/pypy/pypy/changeset/e56dfa6f9309/
Log: (cfbolz, tanzim, arigo)
Essential optimization (<=cfbolz).
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -17,9 +17,13 @@
self.w_value = w_value
+def needs_to_unwrap_cell(space, w_value):
+ return (space.config.objspace.std.withtypeversion and
+ isinstance(w_value, TypeCell))
+
+
def unwrap_cell(space, w_value):
- if (space.config.objspace.std.withtypeversion and
- isinstance(w_value, TypeCell)):
+ if needs_to_unwrap_cell(space, w_value):
return w_value.w_value
return w_value
@@ -366,8 +370,11 @@
tup = w_self._lookup_where(name)
return tup
name = promote_string(name)
- w_class, w_value = w_self._pure_lookup_where_with_method_cache(name,
version_tag)
- return w_class, unwrap_cell(space, w_value)
+ tup_w = w_self._pure_lookup_where_with_method_cache(name, version_tag)
+ w_class, w_value = tup_w
+ if needs_to_unwrap_cell(space, w_value):
+ return w_class, w_value.value
+ return tup_w # don't make a new tuple, reuse the old one
def _pure_lookup_where_possibly_with_method_cache(w_self, name,
version_tag):
if w_self.space.config.objspace.std.withmethodcache:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit