These are chat archives for dropbox/pyston
import time for i in xrange(100000): try: start = time.time() float("hi") except: elapsed = time.time() - start print "%4.1fms" % (elapsed * 1000.0,)
36 0.0ms 1 1.0ms 37 0.0ms 1 1.0ms 36 0.0ms ...
compile filter : Variable(var) took 1.9ms= pyston
compile filter : Variable(var) took 0.0ms= cpython
float(var). in this case, var ==
__float__conversion in unicodeobject.c?
_U_dyn_register- our start ip offset was wrong
PyNumberMethodsmembers or have to reimplement the binaryop/ternaryop functions: I copied the implementation from
ternary_opover but it wont work correctly.... For example __pow(int, long, long)
tp_as_number[nb_power]from the lhs (which in the example is an int) and calls it. int.pow(long, long) is unimplemented (also in cpython) so it retrieves the
tp_as_number[nb_power]function of the second argument (long) and tries the same...
long.__pow__(int, long, long)is implemented so this should work, but it won't in pyston because all of the
tp_as_number[nb_power]implementations are just
slot_nb_powerwrappers which call the "
__pow__" attribute of the argument passed as first which will always be the int.
powfunction is called it will call the
ternary_opfunction (it supports a 3. modulo arg). This one will retrieve the pow function implementation of all 3 passed args and try them one after another until one is implemented. In cpython every
tp_as_numberentry will point to the implementation of the function (for capi types). In pyston this will just be a wrapper which will call the
__pow__attribute on the first argument. This means we loose the ability to call a different implementation because it will always be the one of the first argument and we can't swap arguments because this would change the result.
ternary_opso that it directly calls the
__pow__attribute (or the one which we want to access) instead of going thru
tp_as_numberor we could supply non wrapper implementations for this function... But now I'm thinking changing it to directly call the attribute is much better and much less code to change...