Hi all,
between some interesting and a lot of not-so-interesting talks here at
oospla, I also find the time to hack a bit on pypy :-).
Yesterday I tried the hand-written optimization attached to this mail;
it seems to make pystone about 6% faster; it's not much, but it's not
even so few not to take into account, IMHO. Btw, richards does not
show any improvement, as expected.
Also, it seems that it makes pypy-cli slower, at least on mono; this
is somewhat surprising, because IronPython entirely relies on this
kind of if-else if tests to dispath all operations... I would have bet
that our multimethod dispatching was slower, but it does not seems
so. I should try also on MS .NET, though.
I know that this is not the way to do such an optimization; I guess
that the correct way would be to teach the mutlimethod installer which
are the "hot" cases to test first, before going for a full dispatch;
I've not clue how to do it, though. :-)
ciao Anto
Index: objspace/descroperation.py
===================================================================
--- objspace/descroperation.py (revision 47491)
+++ objspace/descroperation.py (working copy)
@@ -413,6 +413,19 @@
def _make_binop_impl(symbol, specialnames):
left, right = specialnames
def binop_impl(space, w_obj1, w_obj2):
+ if symbol == '+':
+ from pypy.objspace.std.intobject import W_IntObject, wrapint
+ from pypy.objspace.std.longobject import add__Long_Long,
delegate_Int2Long
+ from pypy.rlib.rarithmetic import ovfcheck
+ if isinstance(w_obj1, W_IntObject) and isinstance(w_obj2,
W_IntObject):
+ x = w_obj1.intval
+ y = w_obj2.intval
+ try:
+ z = ovfcheck(x + y)
+ except OverflowError:
+ return add__Long_Long(space, delegate_Int2Long(space,
w_obj1), delegate_Int2Long(space, w_obj2))
+ return wrapint(space, z)
+
w_typ1 = space.type(w_obj1)
w_typ2 = space.type(w_obj2)
w_left_src, w_left_impl = space.lookup_in_type_where(w_typ1, left)
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev