[pypy-svn] r8827 - pypy/dist/pypy/lib

tismer at codespeak.net tismer at codespeak.net
Thu Feb 3 16:00:00 CET 2005


Author: tismer
Date: Thu Feb  3 16:00:00 2005
New Revision: 8827

Modified:
   pypy/dist/pypy/lib/_classobj.py
Log:
complicated the uid masking a little,
avoiding to create a const larger than word size.
This is relevant for generating interp-level.
Well, maybe this could be avoided by generating
long object calls instead of refusing.

Modified: pypy/dist/pypy/lib/_classobj.py
==============================================================================
--- pypy/dist/pypy/lib/_classobj.py	(original)
+++ pypy/dist/pypy/lib/_classobj.py	Thu Feb  3 16:00:00 2005
@@ -8,10 +8,14 @@
 obj_setattr = object.__setattr__
 obj_getattribute = object.__getattribute__
 
-MASK = sys.maxint * 2 + 2
+MASK = sys.maxint * 2 + 1
 
 def uid(o):
-    return (MASK + id(o)) & (MASK-1)
+    v = id(o)
+    if v < 0:
+        v += MASK
+        v += 1
+    return v & MASK
 
 def type_err(arg, expected, v):
    return TypeError("argument %s must be %s, not %s" % (arg, expected, type(v).__name__))



More information about the Pypy-commit mailing list