chumicro-compat
Stdlib polyfills for the bits CircuitPython and MicroPython skipped.
Import from chumicro_compat instead of the stdlib and your code works everywhere. CPython gets the real C implementation (zero overhead); CircuitPython and MicroPython get a lightweight pure-Python version of the same public API.
Part of the ChuMicro family — small, focused Python libraries for microcontrollers and laptops. Browse all libraries.
Install
# CircuitPython (after `circup bundle-add ChuMicro/ChuMicro-Bundle`)
circup install chumicro_compat
# MicroPython
mpremote mip install github:ChuMicro/ChuMicro-Bundle/chumicro_compat
# CPython
pip install chumicro-compat
For bundle setup, pre-compiled .mpy bundles, the experimental channel, and details on PyPI naming, see the chumicro INSTALL guide.
Quick example
from chumicro_compat.functools import partial
def set_led(pin: int, brightness: int) -> None:
"""Set an LED pin to a brightness level."""
print(f"pin {pin} → {brightness}%")
# Freeze the pin, vary the brightness later.
set_status_led = partial(set_led, 13)
set_status_led(50) # pin 13 → 50%
set_status_led(100) # pin 13 → 100%
What's included
functools
| Symbol | Description |
|---|---|
partial(func, *args, **keywords) |
Freeze positional and keyword arguments to a callable |
partial.func |
The original wrapped callable |
partial.args |
Frozen positional arguments (tuple) |
partial.keywords |
Frozen keyword arguments (dict) |
Platform support
| Runtime | What happens |
|---|---|
| CPython | Uses the built-in functools.partial directly — zero overhead |
| MicroPython | Lightweight pure-Python replacement |
| CircuitPython | Lightweight pure-Python replacement |
The public API (.func, .args, .keywords, __call__, __repr__) is identical across all runtimes.
Where this fits
Leaf — no upstream ChuMicro deps. Used directly by any library or app that wants stdlib features (functools.partial, …) missing from CircuitPython / MicroPython.
Examples
| Example | What it shows |
|---|---|
partial_basic.py |
Freeze one argument to a function |
partial_keyword_override.py |
Freeze keyword args, override at call time |
partial_callback.py |
Wire a callback with frozen context (embedded pattern) |
Contributing
Working on chumicro-compat itself? Clone the mono-repo if you haven't already — the rest of the workflow assumes you're inside that workspace.
pip install -e .[test]
pytest tests/ # host-side tests
pytest functional_tests/ # on-device tests (needs a board registered in devices.yml)
Register a board before running functional tests: chumicro-workspace add-device <id> --address <port>.
Docs
📖 Stable docs · Experimental docs
Find this library
- PyPI: chumicro-compat
- Bundle: ChuMicro-Bundle (CircuitPython & MicroPython)
- Experimental bundle: ChuMicro-Bundle-Experimental
- Source: libraries/compat
License
Metadata
Release files for chumicro-compat 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| chumicro_compat-0.3.1.tar.gz | 9.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chumicro_compat-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.8 kB
Release files / chumicro_compat-0.3.1.tar.gz
| Download URL | chumicro_compat-0.3.1.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d28cf751df98f0f0ca936d59d41310a62a614b8944bfe8af0c5c4ee003064e7e
|
|
BLAKE2b-256 checksum How to use checksums |
831980ad70b72546933e20d2c11319f3bea08a9831a60c7e89364ac27066832a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.
Transparency logRelease files / chumicro_compat-0.3.1-py3-none-any.whl
| Download URL | chumicro_compat-0.3.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8deb48c678afcf8fea2c3f1807ddc810dfa0310641e5348ee1d0cc6c44cf00b
|
|
BLAKE2b-256 checksum How to use checksums |
8496adc4f26d328d3d3b3844e0682c25f494bdc505e8346be4e8d7d7205dd3d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.
Transparency log