Cross-runtime compatibility polyfills for CircuitPython, MicroPython, and CPython — functools.partial and more.
Project description
chumicro-compat
Standard library features that CircuitPython and MicroPython are missing.
Import from chumicro_compat instead of the stdlib and your code works everywhere. On CPython it re-exports the real C implementations (zero overhead); on microcontrollers it provides lightweight pure-Python versions.
Part of the ChuMicro family — small, focused Python libraries for microcontrollers and laptops. See all libraries.
Installation
CircuitPython (circup)
circup is CircuitPython's package manager — it uses bundles to find third-party packages. Register the ChuMicro bundle once, then install by name:
circup bundle-add ChuMicro/ChuMicro-Bundle
circup install chumicro-compat
MicroPython (mip)
mpremote mip install github:ChuMicro/ChuMicro-Bundle/chumicro_compat
CPython (pip)
pip install chumicro-compat
Experimental (pre-release) versions and channel switching
Pre-release builds are published automatically when a library version is bumped. Do not register both bundles simultaneously — circup may pick either version for a given package.
# CircuitPython — switch to experimental
circup bundle-remove ChuMicro/ChuMicro-Bundle # skip if never added
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
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.
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) |
Docs
📖 Stable docs · Experimental docs
Find this library
- PyPI: chumicro-compat
- Bundle: ChuMicro-Bundle (CircuitPython & MicroPython)
- Experimental bundle: ChuMicro-Bundle-Experimental
- Source: libraries/compat
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-0.1.21.tar.gz.
File metadata
- Download URL: chumicro_compat-0.1.21.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76cb970d013805f0cc7a4b11bdb450c07c2c4d5f2b43483c0e9b2541906e0abc
|
|
| MD5 |
cf0e88c96cfaf9fe7f4f3cb2476ef244
|
|
| BLAKE2b-256 |
179de3987369f526c5032249bb16856371723074037336a017c632f32d1f13e8
|
Provenance
The following attestation bundles were made for chumicro_compat-0.1.21.tar.gz:
Publisher:
promote.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-0.1.21.tar.gz -
Subject digest:
76cb970d013805f0cc7a4b11bdb450c07c2c4d5f2b43483c0e9b2541906e0abc - Sigstore transparency entry: 1280189352
- Sigstore integration time:
-
Permalink:
ChuMicro/ChuMicro@22713e830419f22e075c56c68fadcc7fc56eb86f -
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:
promote.yml@22713e830419f22e075c56c68fadcc7fc56eb86f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file chumicro_compat-0.1.21-py3-none-any.whl.
File metadata
- Download URL: chumicro_compat-0.1.21-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a738224c8efcc56444a918fa7abec3f12d0674bcaffa6f0787d75daece8eda25
|
|
| MD5 |
e224fa630d0a1cfa98fbaef0deffba95
|
|
| BLAKE2b-256 |
559716fccd3ac15708d522154cd60d1f19d31c7a27de00bbb8e531c9cca7da78
|
Provenance
The following attestation bundles were made for chumicro_compat-0.1.21-py3-none-any.whl:
Publisher:
promote.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-0.1.21-py3-none-any.whl -
Subject digest:
a738224c8efcc56444a918fa7abec3f12d0674bcaffa6f0787d75daece8eda25 - Sigstore transparency entry: 1280189357
- Sigstore integration time:
-
Permalink:
ChuMicro/ChuMicro@22713e830419f22e075c56c68fadcc7fc56eb86f -
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:
promote.yml@22713e830419f22e075c56c68fadcc7fc56eb86f -
Trigger Event:
workflow_dispatch
-
Statement type: