Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r59333:9d66e87f2fbe
Date: 2012-12-05 21:21 +0100
http://bitbucket.org/pypy/pypy/changeset/9d66e87f2fbe/
Log: Minimal change to skip creation of all W_IntObject: redirect wrapint
to space.newlong.
diff --git a/pypy/objspace/std/inttype.py b/pypy/objspace/std/inttype.py
--- a/pypy/objspace/std/inttype.py
+++ b/pypy/objspace/std/inttype.py
@@ -40,34 +40,37 @@
## return descr_from_bytes(space, space.w_int, s, byteorder)
def wrapint(space, x):
- if space.config.objspace.std.withsmallint:
- from pypy.objspace.std.smallintobject import W_SmallIntObject
- try:
- return W_SmallIntObject(x)
- except OverflowError:
- from pypy.objspace.std.intobject import W_IntObject
- return W_IntObject(x)
- elif space.config.objspace.std.withprebuiltint:
- from pypy.objspace.std.intobject import W_IntObject
- lower = space.config.objspace.std.prebuiltintfrom
- upper = space.config.objspace.std.prebuiltintto
- # use r_uint to perform a single comparison (this whole function
- # is getting inlined into every caller so keeping the branching
- # to a minimum is a good idea)
- index = r_uint(x - lower)
- if index >= r_uint(upper - lower):
- w_res = instantiate(W_IntObject)
- else:
- w_res = W_IntObject.PREBUILT[index]
- # obscure hack to help the CPU cache: we store 'x' even into
- # a prebuilt integer's intval. This makes sure that the intval
- # field is present in the cache in the common case where it is
- # quickly reused. (we could use a prefetch hint if we had that)
- w_res.intval = x
- return w_res
- else:
- from pypy.objspace.std.intobject import W_IntObject
- return W_IntObject(x)
+ return space.newlong(x)
+
+## def wrapint(space, x):
+## if space.config.objspace.std.withsmallint:
+## from pypy.objspace.std.smallintobject import W_SmallIntObject
+## try:
+## return W_SmallIntObject(x)
+## except OverflowError:
+## from pypy.objspace.std.intobject import W_IntObject
+## return W_IntObject(x)
+## elif space.config.objspace.std.withprebuiltint:
+## from pypy.objspace.std.intobject import W_IntObject
+## lower = space.config.objspace.std.prebuiltintfrom
+## upper = space.config.objspace.std.prebuiltintto
+## # use r_uint to perform a single comparison (this whole function
+## # is getting inlined into every caller so keeping the branching
+## # to a minimum is a good idea)
+## index = r_uint(x - lower)
+## if index >= r_uint(upper - lower):
+## w_res = instantiate(W_IntObject)
+## else:
+## w_res = W_IntObject.PREBUILT[index]
+## # obscure hack to help the CPU cache: we store 'x' even into
+## # a prebuilt integer's intval. This makes sure that the intval
+## # field is present in the cache in the common case where it is
+## # quickly reused. (we could use a prefetch hint if we had that)
+## w_res.intval = x
+## return w_res
+## else:
+## from pypy.objspace.std.intobject import W_IntObject
+## return W_IntObject(x)
# ____________________________________________________________
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit