Skip to main content

No project description provided

Project description

chumicro-compat

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

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

# CPython (pip)
pip install chumicro-compat

# CircuitPython (circup)
circup bundle-add ChuMicro/ChuMicro-Bundle
circup install chumicro-compat

# MicroPython (mip)
mpremote mip install github:ChuMicro/ChuMicro-Bundle/chumicro_compat

For experimental (pre-release) versions from the develop branch:

pip install chumicro-compat-experimental
circup bundle-add ChuMicro/ChuMicro-Bundle-Experimental
circup install chumicro-compat
mpremote mip install github:ChuMicro/ChuMicro-Bundle-Experimental/chumicro_compat

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

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)

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.7.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

chumicro_compat_experimental-0.1.7-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for chumicro_compat_experimental-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9e1bb552996f527ec9e721adb4e33eb567f4f4dafe431fd406461b542af74730
MD5 13dd5d164b5b6de1bac89ff5bdde9c1a
BLAKE2b-256 3343fdc15ad8fe01f44b89a0dc687e3aafd19a8fbfb4a05d0d94d07ed5c61a45

See more details on using hashes here.

Provenance

The following attestation bundles were made for chumicro_compat_experimental-0.1.7.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.7-py3-none-any.whl.

File metadata

File hashes

Hashes for chumicro_compat_experimental-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 0449f3c787ebfaad614173a5ca425d4cd37522e72d19b0b795e812a1adc8a9f5
MD5 8a6afa7de75c6a4fb19cf16226d6da3a
BLAKE2b-256 792f7b86bd3425a4262cbcfa56e8a87ee535c75e6c198051767f9b71d2b94cbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for chumicro_compat_experimental-0.1.7-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