typedunits
A fast units and dimensions library with support for static dimensionality checking and protobuffer serialization.
What it is and what it does
TypedUnits is a Cython-based library that adds dimensional analysis to Python arithmetic. It lets you attach units to numbers and enforces that only compatible units can be combined—adding meters to kilometers works, but adding meters to seconds fails at runtime or, with static type hints, at type-check time. The library ships precompiled wheels for modern Python versions and supports protobuffer serialization for a selected set of units.
The core use case is scientific and engineering code where dimensional consistency matters: you can write functions that accept only specific unit types, and mypy will catch type mismatches. It also provides array support via numpy integration and can convert values to base SI units for inspection or comparison.
Use it for:
- Physics simulations where dimensional consistency prevents unit-conversion bugs.
- Type-safe function signatures that reject incompatible unit types at type-check time.
- Serializing and deserializing physical quantities via protobuffer for inter-process communication.
- Scientific data pipelines where unit tracking and validation reduce calculation errors.
- Array-based computations on quantities with consistent dimensionality.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements unit of measurement arithmetic with static type checking and protobuffer serialization support, allowing operations on quantities with compatible units.
Yes, if you work with physical quantities and want compile-time dimensional safety. The active maintenance, permissive license, and precompiled wheels make it low-friction to adopt. No known vulnerabilities. Start with the caveat that protobuffer support is limited to selected units—verify your units are covered before relying on serialization.
Install
typedunits on PyPI
pip
pip install typedunitsuv
uv add typedunitspoetry
poetry add typedunitsInstalling typedunits
Before you install
Medium install friction due to compiled Cython wheels; precompiled binaries available for Python 3.10–3.13 on macOS, Linux, and Windows. Active maintenance with recent commits and a permissive Apache 2 license.
License in practice
Apache 2 is permissive; you can use, modify, and distribute typedunits freely in commercial and private projects, provided you include the license notice.
Quickstart
pip install typedunits
from typedunits.units import meter, km, MHz
print(5 * meter + km)
print(3 * MHz)
Requires Python 3.10 or later; precompiled wheels available for common platforms, but building from source requires Cython.
Verify before relying
- Whether protobuffer serialization covers the units you need (documentation notes only selected units are supported).
- Performance characteristics compared to other units libraries in your use case.
- Whether mypy integration works reliably with your type checker configuration.
Package facts
| License | Apache 2 (permissive) |
| Python support | supports the current Python release (>=3.10.0) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 5 — attrs, cython, numpy, protobuf, pyparsing |
| Maintenance | actively maintained — 123 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 93,034/month — #13,406 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: typedunits-0.0.2-cp310-cp310-macosx_11_0_arm64.whl; typedunits-0.0.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; typedunits-0.0.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; typedunits-0.0.2-cp310-cp310-win32.whl; typedunits-0.0.2-cp310-cp310-win_amd64.whl; typedunits-0.0.2-cp311-cp311-macosx_11_0_arm64.whl; typedunits-0.0.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; typedunits-0.0.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; typedunits-0.0.2-cp311-cp311-win32.whl; typedunits-0.0.2-cp311-cp311-win_amd64.whl; typedunits-0.0.2-cp312-cp312-macosx_11_0_arm64.whl; typedunits-0.0.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; typedunits-0.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; typedunits-0.0.2-cp312-cp312-win32.whl; typedunits-0.0.2-cp312-cp312-win_amd64.whl; typedunits-0.0.2-cp313-cp313-macosx_11_0_arm64.whl; typedunits-0.0.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; typedunits-0.0.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; typedunits-0.0.2-cp313-cp313-win32.whl; typedunits-0.0.2-cp313-cp313-win_amd64.whl
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
PintPint defines, operates on, and converts between…
permissive · top 5,000 on PyPI
quantitiesQuantities handles arithmetic and unit…
unclear · top 15,000 on PyPI
measurementProvides unit-aware measurement objects for…
permissive · top 5,000 on PyPI
unytAttaches units to NumPy arrays and provides…
permissive · top 15,000 on PyPI
isqxisqx provides type-annotation-friendly metadata…
permissive · top 15,000 on PyPI
pint-xarrayAdds physical units support to xarray datasets…
permissive · top 15,000 on PyPI
Pint-PandasPint-Pandas adds physical unit support to…
permissive · top 15,000 on PyPI
ansys-unitsManages physical quantities with numerical…
permissive · top 15,000 on PyPI
hepunitsProvides units and physical constants in the…
permissive · top 15,000 on PyPI
python-flintPython bindings for FLINT and Arb that provide…
copyleft · top 15,000 on PyPI