Tips or strategies to understanding how CPython works under the hood (Posting On Python-List Prohibited)

bartc bc at freeuk.com
Wed Jan 10 21:09:25 EST 2018


On 10/01/2018 23:31, Lawrence D’Oliveiro wrote:
> On Thursday, January 11, 2018 at 1:08:25 AM UTC+13, bartc wrote:
>>
>> But I'm not convinced that register-based is necessarily faster.
> 
> Not if your code is dominated by memory accesses, as a dynamic language is likely to be. But ask the people who design machine architectures, and who write compilers for them for languages like C--they’ll tell you it makes a helluva difference.
> 

I'm not sure what you mean here. The subject is byte-code interpreters 
not statically compiled languages running native code, which are 
obviously better off using real hardware registers.

The 'registers' in this example - for actual byte-code execution not 
what happens in pypy and LuaJIT - don't appear to be actual hardware 
registers. They can't be when an implementation is 100% high level code.

They are just a different scheme to address instruction operands stored 
in memory, which can offer some advantages, with a few downsides.


(I've been writing byte-code interpreters for stack-based VMs for years. 
I've never had much luck moving away from that model.

At the moment they generally run the same algorithms a bit faster than 
register-based Lua, but can also be trivially accelerated to be several 
times faster, while still executing sequential byte-code.

Not as fast as LuaJIT, but what goes on in that is beyond the methods 
discussed here for CPython and such.)


-- 
bartc



More information about the Python-list mailing list