Registry / serialization / pybcj
library1.0.8pypypi✓ verified 34d ago

pybcj is a Python library that provides the BCJ (Branch/Call/Jump) filter, often used as a pre-processing step for data compression algorithms like LZMA (e.g., in xz). It aims to improve compression ratios for executable code by converting relative branch/call/jump targets to absolute addresses. The current version is 1.0.7, and releases are generally infrequent, driven by bug fixes or minor enhancements.

pip install pybcj
INSTALL
IMPORT
SIG · PYBCJ
P
pybcj
serializationpythonv1.0.8
Install
1.6s avg
Import
90ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.0.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.096s · 17.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.084s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BCJEncoder
✓ from bcj import BCJEncoder
✗ from pybcj import BCJEncoder
BCJDecoder
✓ from bcj import BCJDecoder
✗ from pybcj import BCJDecoder
version
✓ from bcj import version
✗ from pybcj import version

This quickstart demonstrates two ways to use pybcj: with `BCJEncoder`/`BCJDecoder` objects utilizing `io.BytesIO` streams, and with the simpler top-level `compress_buffer`/`decompress_buffer` functions for direct byte array processing.

from pybcj import BCJEncoder, BCJDecoder, compress_buffer, decompress_buffer import io # Example data (simulating executable code, BCJ works best on actual binaries) original_data = b"\xe8\x00\x00\x00\x00\x48\x83\xec\x28\xe9\x05\x00\x00\x00\x90\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" print(f"Original data length: {len(original_data)}") # --- Method 1: Using BCJEncoder/Decoder objects with streams --- # Encode encoder = BCJEncoder() encoded_stream = io.BytesIO() encoder.compress(original_data, encoded_stream) encoded_data_stream = encoded_stream.getvalue() print(f"Encoded (stream) data length: {len(encoded_data_stream)}") # Decode decoder = BCJDecoder() decoded_stream = io.BytesIO() decoder.decompress(encoded_data_stream, decoded_stream) decoded_data_stream = decoded_stream.getvalue() print(f"Decoded (stream) data length: {len(decoded_data_stream)}") assert original_data == decoded_data_stream print("Stream method: Original and decoded data match!") # --- Method 2: Using top-level compress_buffer/decompress_buffer functions --- encoded_data_buffer = compress_buffer(original_data) print(f"Encoded (buffer) data length: {len(encoded_data_buffer)}") decoded_data_buffer = decompress_buffer(encoded_data_buffer) print(f"Decoded (buffer) data length: {len(decoded_data_buffer)}") assert original_data == decoded_data_buffer print("Buffer method: Original and decoded data match!")
Debug
Known issues
gotchapybcj requires Python 3.10 or newer. Installing on older Python versions will result in a `Requires-Python` error.
fix
Ensure your Python environment is 3.10 or newer. Use `python --version` to check.
affects: <1.0.0 (all versions)
gotchaThe `BCJEncoder.compress()` and `BCJDecoder.decompress()` methods expect stream-like objects (e.g., `io.BytesIO`) as input/output targets. For direct byte array to byte array operations, use the top-level `compress_buffer()` and `decompress_buffer()` functions.
fix
If working with byte strings directly, use `from pybcj import compress_buffer, decompress_buffer`. If using `BCJEncoder`/`BCJDecoder` objects, wrap your byte data in `io.BytesIO(your_bytes_data)`.
affects: All versions
deprecatedVersions prior to `1.0.0` (specifically `0.x` releases) might have had different API structures or missing helper functions like `compress_buffer`/`decompress_buffer`. These older versions are no longer actively maintained.
fix
Always upgrade to the latest stable version (`pip install --upgrade pybcj`) to ensure access to the most robust and complete API, including the convenient buffer functions.
affects: <1.0.0
Upgrade
Version history
1.0.8latest on PyPI · released Jul 16, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
pybcj — pip install pybcj · libregistry