Skip to main content

Cross-runtime compatibility polyfills for CircuitPython, MicroPython, and CPython — functools.partial and more.

Project description

chumicro-compat

Cross-runtime compatibility polyfills for CircuitPython, MicroPython, and CPython.

Provides lightweight reimplementations of CPython standard-library features that are missing or incomplete on microcontroller runtimes. On CPython, re-exports the real C implementations for zero overhead.

Installation

CircuitPython (circup)

Register the ChuMicro bundle (remove the other channel first if switching):

circup bundle-remove ChuMicro/ChuMicro-Bundle-Experimental   # skip if never added
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

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
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, brightness):
    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 Implementation
CPython Re-exports the C-implemented functools.partial directly
MicroPython Pure-Python polyfill with __slots__
CircuitPython Pure-Python polyfill with __slots__

The public API (.func, .args, .keywords, __call__, __repr__) is identical across all runtimes.

Docs

📖 Stable docs · Experimental docs

Browse on GitHub:

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)

Find this library

PyPI: chumicro-compat Bundle: ChuMicro-Bundle (CircuitPython & MicroPython) Source: ChuMicro/ChuMicro — cross-runtime Python libraries for ESP32, RP2040, and other microcontrollers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chumicro_compat_experimental-0.1.15.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file chumicro_compat_experimental-0.1.15.tar.gz.

File metadata

File hashes

Hashes for chumicro_compat_experimental-0.1.15.tar.gz
Algorithm Hash digest
SHA256 dd5d83c207b039b639dbb9ab4dac70eec1e8f49bc1563da9d1e807b1aabf3831
MD5 10f4fed95ebc44f9a89a9407df877932
BLAKE2b-256 5ec5b3a785c538f41e4b189e1229922f1a77e2084c4534e8df8cd01dfbcba813

See more details on using hashes here.

Provenance

The following attestation bundles were made for chumicro_compat_experimental-0.1.15.tar.gz:

Publisher: release.yml on ChuMicro/ChuMicro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chumicro_compat_experimental-0.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for chumicro_compat_experimental-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 8790773f334ba4767f4c632aef0d050ea43df1eaa2bb85071a1cdb939a1f5633
MD5 f21e0e5d8658b384ca4b44170e6e1025
BLAKE2b-256 980cba271e885525dfe53e0b2cb0eca9ce1f7a1e51ae7f3dcb9a5b6913527def

See more details on using hashes here.

Provenance

The following attestation bundles were made for chumicro_compat_experimental-0.1.15-py3-none-any.whl:

Publisher: release.yml on ChuMicro/ChuMicro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page