Skip to main content

Python module to generate and modify bytecode

Project description

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.

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bytecode-0.16.0.tar.gz (102.1 kB view details)

Uploaded Source

Built Distribution

bytecode-0.16.0-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

Details for the file bytecode-0.16.0.tar.gz.

File metadata

  • Download URL: bytecode-0.16.0.tar.gz
  • Upload date:
  • Size: 102.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for bytecode-0.16.0.tar.gz
Algorithm Hash digest
SHA256 06676a3c3bccc9d3dc73ee625650ea57df2bc117358826f4f290f0e1faa42292
MD5 7fa490a509a864f93d60662ad963eef4
BLAKE2b-256 97a9a9148f6155206d52a5be8a42e25db7aa88df7d8fe2212685f5dcd4fc256d

See more details on using hashes here.

File details

Details for the file bytecode-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: bytecode-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 41.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for bytecode-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76080b7c0eb9e7e17f961d61fd06e933aa47f3b753770a3249537439d8203a25
MD5 4356ac1f1c44d12bf6965e6ce9e7359b
BLAKE2b-256 6058644f89db71b41598ccfd4662a60533790699d0294241d1903207e5a993af

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page