Beyond bytecode: a wordcode-based Python

Bytecode representation is very common and many languages implementations use it in some form, because it simplifies compilers and virtual machines creation, giving also very often object code portability.
In this talk a new bytecode-free CPython 2.6 implementation will be presented: the "wordcode" solution. A wordcode is a word (16 bits, two bytes, in this case) used to represent codes assigned to single elementary operations to execute.
This new operation encoding enabled to simplify the execution of the virtual machine main cycle, improving understanding, maintenance and extensibility at the same time. Some controls generating mispredicted branches hurting execution of modern CPU have been removed.
Comparing executed operations, there is a 30% lower space on average compared to bytecode, so reducing both .pyc file size and memory allocation when loaded in memory. The wordcode access reduces the number of CPU load instructions, saving memory bandwidth also.
ceval.c (and opcode.h), ast.c, compile.c and peephole.c files will be analyzed, which resemble virtual machine, AST generator, compiler and peephole optimizer respectively, comparing them with the current bytecode-based implementation.

pycon3 in the track Diffondere Python.

Download


Language
IT
Duration
60 minutes