qunits logo qunits logo

A performant, verbose and generic physical unit system.

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

API Doc

Modules

qunits is split into four submodules.

  • dimension   Contains the dimension definitions.
  • prefix   Contains the prefixes, the exponent maps and the unit contexts.
  • registry   Contains the unit registry u.
  • unit   Contains the Unit and the Quantity classes.

The registry and the classes can be imported from qunits directly. Dimensions and contexts are only needed to define custom units.

from qunits import Quantity, Unit, u
from qunits.dimension import Length
from qunits.prefix import Context

Registry

The unit registry u contains many predefined units, including prefixes, such as kilo and milli. Depending on the unit, the prefixes extend from $10^{-30}$ to $10^{30}$.

Units

Physical units are defined by the Unit class. Each unit has a dimension, a scale relative to the SI unit of its dimension and a context. The custom units tutorial shows how to define your own units.

Quantities

Numerical objects with physical units are defined by the Quantity class. Its page lists the supported arithmetic and numpy functions.