A bytecode-engineering library for python 3.11.
This project does not have a pip package (yet). To install it, the assembler.py
file needs to be copied into the project it's used in.
This library (obviously) requires a lot of knowledge about python's bytecode syntax. If you're unsure about certain things, you can use python's compile
combined with dis
to figure certain things out. Here's an example:
import dis
def dump(source):
compiled = compile(source, "", "exec")
dis.dis(compiled)
dump("print(123)")
The examples.py
file contains examples on how to use the library. The documentation in the library itself also contains some useful help.
Documentation on the specific instructions can be found at the dis
python docs.
If you wonder how specific python snippets look like in bytecode, refer to usage
- The resulting assembly generated by this project needs to be run with python 3.11. No version below 3.11 will be able to parse the bytecode generated with this libary, due to pretty significant changes to the format.