BytecodeAssembler (original) (raw)

peak.util.assembler is a simple bytecode assembler module that handles most low-level bytecode generation details like jump offsets, stack size tracking, line number table generation, constant and variable name index tracking, etc. That way, you can focus your attention on the desired semantics of your bytecode instead of on these mechanical issues.

In addition to a low-level opcode-oriented API for directly generating specific Python bytecodes, this module also offers an extensible mini-AST framework for generating code from high-level specifications. This framework does most of the work needed to transform tree-like structures into linear bytecode instructions, and includes the ability to do compile-time constant folding.

Please see the BytecodeAssembler reference manual for more details.

Changes since version 0.6:

Changes since version 0.5.2:

Changes since version 0.5.1:

Changes since version 0.5:

Changes since version 0.3:

Changes since version 0.2:

Changes since version 0.1:

Changes since version 0.0.1:

There are a few features that aren’t tested yet, and not all opcodes may be fully supported. Also note the following limitations:

If you find any other issues, please let me know.

Please also keep in mind that this is a work in progress, and the API may change if I come up with a better way to do something.

Questions and discussion regarding this software should be directed to thePEAK Mailing List.