[pypy-commit] pypy default: define a constant for the shift amount of the id tagging
cfbolz
pypy.commits at gmail.com
Sat Mar 5 08:30:35 EST 2016
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r82787:73814b195ba5
Date: 2016-03-05 14:29 +0100
http://bitbucket.org/pypy/pypy/changeset/73814b195ba5/
Log: define a constant for the shift amount of the id tagging
diff --git a/pypy/objspace/std/complexobject.py b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -266,11 +266,12 @@
return None
from rpython.rlib.longlong2float import float2longlong
from pypy.objspace.std.util import IDTAG_COMPLEX as tag
+ from pypy.objspace.std.util import IDTAG_SHIFT
real = space.float_w(space.getattr(self, space.wrap("real")))
imag = space.float_w(space.getattr(self, space.wrap("imag")))
real_b = rbigint.fromrarith_int(float2longlong(real))
imag_b = rbigint.fromrarith_int(r_ulonglong(float2longlong(imag)))
- val = real_b.lshift(64).or_(imag_b).lshift(3).int_or_(tag)
+ val = real_b.lshift(64).or_(imag_b).lshift(IDTAG_SHIFT).int_or_(tag)
return space.newlong_from_rbigint(val)
def int(self, space):
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -181,9 +181,10 @@
return None
from rpython.rlib.longlong2float import float2longlong
from pypy.objspace.std.util import IDTAG_FLOAT as tag
+ from pypy.objspace.std.util import IDTAG_SHIFT
val = float2longlong(space.float_w(self))
b = rbigint.fromrarith_int(val)
- b = b.lshift(3).int_or_(tag)
+ b = b.lshift(IDTAG_SHIFT).int_or_(tag)
return space.newlong_from_rbigint(b)
def __repr__(self):
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -24,7 +24,7 @@
from pypy.interpreter.typedef import TypeDef
from pypy.objspace.std import newformat
from pypy.objspace.std.util import (
- BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_INT, wrap_parsestringerror)
+ BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_INT, IDTAG_SHIFT, wrap_parsestringerror)
SENTINEL = object()
@@ -46,7 +46,7 @@
if self.user_overridden_class:
return None
b = space.bigint_w(self)
- b = b.lshift(3).int_or_(IDTAG_INT)
+ b = b.lshift(IDTAG_SHIFT).int_or_(IDTAG_INT)
return space.newlong_from_rbigint(b)
def int(self, space):
diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -16,7 +16,7 @@
from pypy.objspace.std import newformat
from pypy.objspace.std.intobject import W_AbstractIntObject
from pypy.objspace.std.util import (
- BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_LONG, wrap_parsestringerror)
+ BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_LONG, IDTAG_SHIFT, wrap_parsestringerror)
def delegate_other(func):
@@ -45,7 +45,7 @@
if self.user_overridden_class:
return None
b = space.bigint_w(self)
- b = b.lshift(3).int_or_(IDTAG_LONG)
+ b = b.lshift(IDTAG_SHIFT).int_or_(IDTAG_LONG)
return space.newlong_from_rbigint(b)
def unwrap(self, space):
diff --git a/pypy/objspace/std/util.py b/pypy/objspace/std/util.py
--- a/pypy/objspace/std/util.py
+++ b/pypy/objspace/std/util.py
@@ -2,6 +2,7 @@
from pypy.interpreter.error import OperationError, oefmt
+IDTAG_SHIFT = 3
IDTAG_INT = 1
IDTAG_LONG = 3
More information about the pypy-commit
mailing list