px
pypx

bytecode

v0.19.0

Python module to generate and modify bytecode

42 KB Python 3.11+ py3-none-anyMIT License1 deps
Diff
$ uv add bytecode

bytecode
Latest release on the Python Cheeseshop (PyPI) Continuous integration Documentation building Code coverage of bytecode on codecov.io Ruff

bytecode is a Python module to generate and modify bytecode.

  • `bytecode project homepage at GitHub

<https://github.com/MatthieuDartiailh/bytecode>`_ (code, bugs)

  • `bytecode documentation

<https://bytecode.readthedocs.io/>`_

  • `Download latest bytecode release at the Python Cheeseshop (PyPI)

<https://pypi.python.org/pypi/bytecode>`_

Install bytecode: python3 -m pip install bytecode. It requires Python 3.8 or newer. The latest release that supports Python 3.7 and 3.6 is 0.13.0. The latest release that supports Python 3.5 is 0.12.0. For Python 2.7 support, have a look at dead-bytecode instead.

Example executing print('Hello World!'):

from bytecode import Instr, Bytecode

bytecode = Bytecode([Instr("LOAD_GLOBAL", (True, 'print')),
                     Instr("LOAD_CONST", 'Hello World!'),
                     Instr("CALL", 1),
                     Instr("POP_TOP"),
                     Instr("LOAD_CONST", None),
                     Instr("RETURN_VALUE")])
code = bytecode.to_code()
exec(code)

Details

Version
0.19.0
License
MIT License
Python
>=3.11
Maintainer
Victor Stinner <[email protected]>

Release Cadence

3
releases in the past year
avg 153 days between releases

Maintainers