Announcing bytecodehacks 0.10

Christian Tismer tismer at appliedbiometrics.com
Thu May 13 08:22:13 EDT 1999


Michael Scharf wrote:
> 
> Michael Hudson wrote:
> >
> > If you've been following the "Python is too slow" thread of late, you
> > might have noticed my sneaky bytecode rewriting functions.
> 
> But all this does *not* work for JPython I think.

Of course not. And while I love JPython very much, I finally
think that it is a design failure to have no bytecodes, since
they are such a perfect description of a Python program.
I only wished there were a COMMENT opcode, then I could
drop all my .py files and use .pyc only :-)
(take the time machine and read the thread about elipmoc.py)

...

> The most interesting functionality (for me), is hidden in
> bytecodehacks.closure:
> 
>   bind
>   bind_locals
>   bind_now
> 
> With those methods (it seems), I can speedup my functions.
> >From the documentation it's not clear to me, which one to use.
> What should I do, if I just want to "burn" the globals and
> built-ins into my function?
> 
> Looks like great work.

And can be extended quite far. 
Extreme extent: take a class instance which you know you will
use thousands of time, in its current state. You can pull
all methods out of the class hierarchy, bind them through
and make them into local variables. This removes almost all
attribute lookups, and you have something like a bound
function with a true VMT.
Now add some sugar, generate C code, shake it, and Swallow :-)

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home




More information about the Python-list mailing list