On Fri, Mar 1, 2013 at 10:13 PM, Roger Flores email@example.com wrote:
I see both BINARY_XOR and BINARY_AND call a function instead of xor and and. Why? Is there something I can change in my code to let those instructions be used instead? Can xoring two ints really cause an exception?
If it becomes calls to, I guess, rbigint.xor and rbigint.and, it's because these are objects of the Python type "long". PyPy must respect the Python semantics: if you do for example "(1 << 80) >> 80", the result is not 1, but 1L. This said, I guess that the code is expected to manipulate 32-bit unsigned integers, and so should not overflow to long on 64-bit machines. You may want to investigate, in the normal Python way, why you get "long" objects there --- this is not a particularity of PyPy; you can investigate on CPython if you prefer.
If you're running this code on 32-bit machines, then no chance: you're getting "long"s. The only solution would be along the lines I described before, with a W_TwoIntsLongObject, or even a W_UnsignedIntLongObject that can store all long objects between 0 and 2**32-1.