Skip to main content

bitcut

A simple CLI for slicing and assembling binary bit ranges. Aimed at embedded‑style bit‑field hacking and quick validation against datasheets.

  • Ever been annoyed with double checking if the hexadecimal value you are writing to a register actually set specifc bits you want to set?

  • Tired of decoding hex/decimals to see which bits are actually set and triple checking with a datasheet?

Look no further! Bitcut makes it easy to go from binary strings to hex and vice versa.

  • slice a value into bit ranges,
  • splice a value from ranges.

For bit‑field hacking, protocol specs and embedded.


Example Usage

Slice a value into bit ranges:

$ bitcut slice 0x42 6:4 3:0
[6:0] - b'1000010' # Full Slice
[6:4] - b'100'
[3:0] - b'0010'

Splice a value from bit ranges:

$ bitcut splice 6:4=100 3:0=0010
[6:4] - b'100'
[3:0] - b'0010'
Binary String: 01000010
Hexadecimal  : 0x42
Unsigned int : 66

See full help:

$ bitcut --help
$ bitcut slice --help
$ bitcut splice --help

Installation

From a local checkout: (PyPi install incoming)

$ pip install .

(Requires Python ≥3.10.)


Development

This repo uses uv for development

uv venv
uv sync              # installs dependencies + dev deps
uv pip install -e .

Run tests (coverage via pytest.ini):

uv run pytest

Coverage HTML report is written to htmlcov/index.html.


License

MIT

Metadata

Release files for bitcut 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bitcut 0.1.0
File Size Uploaded
bitcut-0.1.0.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bitcut 0.1.0
File Interpreter ABI Platform
bitcut-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / bitcut-0.1.0.tar.gz

Download URL bitcut-0.1.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
68c06f34d44aa24ff56cd7c8b1a812e7a2a24b6662811f72678e3693e6c3a35e
BLAKE2b-256 checksum
How to use checksums
917ed6fc6c273ba4589b9fd91f6bd228a9964dc1e4d8715574384e54d667a77a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.7

Release files / bitcut-0.1.0-py3-none-any.whl

Download URL bitcut-0.1.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
225789939d9e019fa5384c724f59b3bbb565ce3e1bb74f90e5e3cda947e3a382
BLAKE2b-256 checksum
How to use checksums
3d9cda4f2942b6a6588eaf9216b116e3766be85c0a2a382abddca510610659ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page