skillfed

typedunits

A fast units and dimensions library with support for static dimensionality checking and protobuffer serialization.

typedunits v0.0.2 93.0K downloads/30d#13,406 on PyPI10
Permissive license Apache 2 Active released

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 typedunits

uv

uv add typedunits

poetry

poetry add typedunits

Installing 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

unit of measurement arithmeticdimensional analysis pythonstatic type checking unitsphysical quantities libraryunit conversion and arithmeticprotobuffer serialization unitsdimensionality checking
dimensional-analysistype-safe-unitsscientific-computing

More Mathematics packages