Cross-runtime compatibility polyfills for CircuitPython, MicroPython, and CPython — functools.partial and more.
Project description
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-Experimental`)
circup install chumicro_compat
# MicroPython
mpremote mip install github:ChuMicro/ChuMicro-Bundle-Experimental/chumicro_compat
# CPython
pip install chumicro-compat-experimental
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chumicro_compat_experimental-0.3.1.tar.gz.
File metadata
- Download URL: chumicro_compat_experimental-0.3.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d60ac7842cdaf8a05da2eb9152c217e2dd5aa3ea6c0834c572f4ac552e291d5
|
|
| MD5 |
9bc24e1e7db7745aab75fd58aede2c60
|
|
| BLAKE2b-256 |
4ff095cf1b4edfa11c47cb4133d72e031d1af6fee16012b719e9f63971c78fe7
|
Provenance
The following attestation bundles were made for chumicro_compat_experimental-0.3.1.tar.gz:
Publisher:
release.yml on ChuMicro/ChuMicro
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chumicro_compat_experimental-0.3.1.tar.gz -
Subject digest:
4d60ac7842cdaf8a05da2eb9152c217e2dd5aa3ea6c0834c572f4ac552e291d5 - Sigstore transparency entry: 2199635244
- Sigstore integration time:
-
Permalink:
ChuMicro/ChuMicro@bd5a08ba89ce08ea17dd027ff20cebf5d20244f8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ChuMicro
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bd5a08ba89ce08ea17dd027ff20cebf5d20244f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file chumicro_compat_experimental-0.3.1-py3-none-any.whl.
File metadata
- Download URL: chumicro_compat_experimental-0.3.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f57ee73da0662a0eb822cf3e8c89ffc47554c05b690c66a65a363be6c6ee9eb2
|
|
| MD5 |
4895923a036de8af6d49e29d10104364
|
|
| BLAKE2b-256 |
ba90ff2e8c1d032b3735e3f75e871e532916af0e47a050040d44c26239728e2f
|
Provenance
The following attestation bundles were made for chumicro_compat_experimental-0.3.1-py3-none-any.whl:
Publisher:
release.yml on ChuMicro/ChuMicro
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chumicro_compat_experimental-0.3.1-py3-none-any.whl -
Subject digest:
f57ee73da0662a0eb822cf3e8c89ffc47554c05b690c66a65a363be6c6ee9eb2 - Sigstore transparency entry: 2199635307
- Sigstore integration time:
-
Permalink:
ChuMicro/ChuMicro@bd5a08ba89ce08ea17dd027ff20cebf5d20244f8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ChuMicro
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bd5a08ba89ce08ea17dd027ff20cebf5d20244f8 -
Trigger Event:
push
-
Statement type: