[Python-Dev] Python 3 optimizations continued...

Stefan Behnel stefan_ml at behnel.de
Wed Aug 31 09:26:49 CEST 2011


stefan brunthaler, 30.08.2011 22:41:
>> Ok, there there's something else you haven't told us. Are you saying
>> that the original (old) bytecode is still used (and hence written to
>> and read from .pyc files)?
>>
> Short answer: yes.
> Long answer: I added an invocation counter to the code object and keep
> interpreting in the usual Python interpreter until this counter
> reaches a configurable threshold. When it reaches this threshold, I
> create the new instruction format and interpret with this optimized
> representation. All the macros look exactly the same in the source
> code, they are just redefined to use the different instruction format.
> I am at no point serializing this representation or the runtime
> information gathered by me, as any subsequent invocation might have
> different characteristics.

So, basically, you built a JIT compiler but don't want to call it that, 
right? Just because it compiles byte code to other byte code rather than to 
native CPU instructions does not mean it doesn't compile Just In Time.

That actually sounds like a nice feature in general. It could even replace 
(or accompany?) the existing peep hole optimiser as part of a more general 
optimisation architecture, in the sense that it could apply byte code 
optimisations at runtime rather than compile time, potentially based on 
better knowledge about what's actually going on.


> I will remove my development commentaries and create a private
> repository at bitbucket

I agree with the others that it's best to open up your repository for 
everyone who is interested. I can see no reason why you would want to close 
it back down once it's there.

Stefan



More information about the Python-Dev mailing list