[Python-Dev] Pie-thon benchmarks

Tim Peters tim.one at comcast.net
Mon Dec 15 15:21:16 EST 2003

>> "Not that hard" depends on your background.  The idea is to bury Dan
>> under esoteric algorithms from a huge number of obscure specialties
>> <wink>.

[Dan Sugalski]
> Heh. You're expecting me to do far too much work. I plan on tackling
> bytecode optimization only if it turns out that a straightforward
> transform from python bytecode to parrot bytecode is isn't
> sufficiently faster than CPython. Funky algorithms expressed entirely
> in python bytecode won't make much of a difference...

There is a serious point buried in this.  This is how Python spells
small-int multiplication in the bytecode:


And this is how it spells unbounded-int Karatsuba multiplication in the


Same thing, and floating multiply, complex multiply, catenating N copies of
a string, and arbitrary user-defined Python code overloading infix "*" for a
class are spelled BINARY_MULTIPLY in the bytecode too.  There's simply
nothing in the bytecode to distinguish these cases.

It wouldn't be hard for Guido to construct a vanilla-looking Python program
that tickles some of the extreme-win special cases in the type-dependent
implementations of the operators.  That wouldn't be fair, so I'll hit him if
he does <wink>, but in some smaller senses it can't be avoided.  For
example, all idiomatic Python programs use dicts (hashes), and the dict
implementation dynamically keeps track of whether any non-string key has
been added (Python dicts can be indexed by lots of things, not just
strings).  So long as it hasn't, special methods specialized to string keys
are used; but as soon as, e.g., a float key is added, a Python dict switches
to using slower, more-general methods.  None of that is reflected in the
bytecode, of course.  There's a lot of stuff like that.

pystone tickles little of that nature, because pystone is such an *a*typical
Python program.  So, regardless of what the official benchmark turns out to
be, I'll probably be more interested in your pystone result <wink>.

More information about the Python-Dev mailing list