[pypy-svn] r16017 - pypy/dist/pypy/objspace/std
tismer at codespeak.net
tismer at codespeak.net
Fri Aug 12 19:59:00 CEST 2005
Author: tismer
Date: Fri Aug 12 19:58:59 2005
New Revision: 16017
Modified:
pypy/dist/pypy/objspace/std/floatobject.py
pypy/dist/pypy/objspace/std/longobject.py
Log:
corrected a false comment of mine in floatobject.py.
added some commentary for the tiny _get_odd() function in longobject.py,
which is a bit special because it is the only case where you can use
the lowest bit without taking the sign bit into account.
A general get_bit(a,n) operation would be to expensive to be worth it,
unless we explicitly say it ignores the sign.
Modified: pypy/dist/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/floatobject.py (original)
+++ pypy/dist/pypy/objspace/std/floatobject.py Fri Aug 12 19:58:59 2005
@@ -353,7 +353,7 @@
register_all(vars())
-# pow delegation for negative 1st arg
+# pow delegation for negative 2nd arg
def pow_neg__Long_Long_None(space, w_int1, w_int2, thirdarg):
w_float1 = delegate_Long2Float(w_int1)
w_float2 = delegate_Long2Float(w_int2)
Modified: pypy/dist/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/longobject.py (original)
+++ pypy/dist/pypy/objspace/std/longobject.py Fri Aug 12 19:58:59 2005
@@ -1656,4 +1656,9 @@
return bits
def _get_odd(a):
+ # Note: this is a tiny optimization.
+ # Instead of implementing a general "get_bit" operation,
+ # which would be expensive for negative numbers,
+ # get_odd has the nice feature that it is always correct,
+ # no matter what the sign is (two's complement)
return a.digits[0] & 1
More information about the Pypy-commit
mailing list