--- id: typedunits version: "0.0.2" license: Apache 2 license_treatment: permissive maintenance: active --- # typedunits — A fast units and dimensions library with support for static dimensionality checking and protobuffer serialization. License: permissive · Maintenance: active · Downloads: 93.0K/mo ## 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 above — 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 pip install typedunits uv add typedunits 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_current - Install friction: medium - Maintenance: active - Downloads: 93.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags unit of measurement arithmetic, dimensional analysis python, static type checking units, physical quantities library, unit conversion and arithmetic, protobuffer serialization units, dimensionality checking, dimensional-analysis, type-safe-units, scientific-computing [View on SkillFed](https://skillfed.io/packages/typedunits) · [View on PyPI](https://pypi.org/project/typedunits/)