[pypy-dev] Basic math ops

Timothy Baldridge tbaldridge at gmail.com
Tue Mar 8 17:12:51 CET 2011


In my interpreter, I have several primitive wrapper objects:
IntObject, FloatObject, etc.

Currently I'm planning to create functions for every combination:

def add_int_float(i, f):
     return FloatObject(i.int_value() + f.float_value())

then I'd need some sort of dispatch code that would say

if isinstance(arg1, IntObject) and isinstance(arg2, FloatObject):
    return add_int_float(arg1, arg2)

It seems like pypy should have something to do this already. I saw
some information on this but that seemed specific to the Python
interpreter.

What's the recommended procedure on this? Is there a way to tell pypy
"this object wraps a single value, so keep it unwrapped if you can",
or does pypy figure that out automagically?

Thanks,

Timothy

-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)



More information about the Pypy-dev mailing list