Installation
Tamp contains 4 implementations:
A reference desktop CPython implementation that is optimized for readability (and not speed).
A Micropython Native Module implementation (fast).
A Micropython Viper implementation (not recommended, please use Native Module).
A C implementation (with python bindings) for accelerated desktop use and to be used in C projects (very fast).
Desktop Python
The Tamp library and CLI requires Python >=3.8
and can be installed via:
pip install tamp
To install directly from github, you can run:
python -m pip install git+https://github.com/BrianPugh/tamp.git
For development, its recommended to use Poetry:
git clone https://github.com/BrianPugh/tamp.git
cd tamp
poetry install
MicroPython
Native Module
Tamp provides pre-compiled native modules that are easy to install, are small, and are incredibly fast.
Download the appropriate .mpy
file from the release page.
Match the micropython version.
Match the architecture to the microcontroller (e.g.
armv6m
for a pi pico).
Rename the file to tamp.mpy
and transfer it to your board. If using Belay, tamp can be installed by adding the following to pyproject.toml
.
[tool.belay.dependencies]
tamp = "https://github.com/BrianPugh/tamp/releases/download/v1.4.0/tamp-1.4.0-mpy1.22-armv6m.mpy"
Viper
NOT RECOMMENDED, PLEASE USE NATIVE MODULE
For micropython use, there are 3 main files:
tamp/__init__.py
- Always required.tamp/decompressor_viper.py
- Required for on-device decompression.tamp/compressor_viper.py
- Required for on-device compression.
For example, if on-device decompression isn't used, then do not include decompressor_viper.py
.
If manually installing, just copy these files to your microcontroller's /lib/tamp
folder.
If using mip, tamp can be installed by specifying the appropriate package-*.json
file.
mip install github:brianpugh/tamp # Defaults to package.json: Compressor & Decompressor
mip install github:brianpugh/tamp/package-compressor.json # Compressor only
mip install github:brianpugh/tamp/package-decompressor.json # Decompressor only
If using Belay, tamp can be installed by adding the following to pyproject.toml
.
[tool.belay.dependencies]
tamp = [
"https://github.com/BrianPugh/tamp/blob/main/tamp/__init__.py",
"https://github.com/BrianPugh/tamp/blob/main/tamp/compressor_viper.py",
"https://github.com/BrianPugh/tamp/blob/main/tamp/decompressor_viper.py",
]
C
Copy the tamp/_c_src/tamp
folder into your project.
For more information, see C Library.