hepunits
Units and constants in the HEP system of units
What it is and what it does
hepunits is a Python library that defines the standard units and physical constants used in high-energy physics, based on the CLHEP system rather than SI units. The core difference is that HEP uses millimeters for length, nanoseconds for time, and MeV for energy as its base units, reflecting conventions used in major physics software like GEANT4 and Gaudi. The package provides two main modules: constants (physical constants and commonly used values) and units (length, time, energy, and other dimensional quantities).
You use it by multiplying numerical values by unit objects to create dimensioned quantities, then dividing by units to extract values in a desired unit system. For example, defining a 1 GeV mass window as `1 * GeV` and retrieving an energy resolution in GeV as `energy_resolution() / GeV`. The package also optionally integrates with Pint for interoperability with a more general-purpose units library, though this is not required for basic use.
Use it for:
- Define and work with particle lifetimes and decay distances in particle physics simulations and analysis code
- Perform energy and momentum calculations in high-energy physics experiments using standard HEP conventions
- Convert between HEP units and SI or other unit systems when interfacing with external libraries or publishing results
- Store dimensioned quantities consistently in data structures while keeping internal representation in HEP units
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides units and physical constants in the HEP (High Energy Physics) system of units, derived from CLHEP, for use in particle physics calculations and simulations.
Yes. The package has zero security vulnerabilities, low install friction, active maintenance, and is designed for a specific and well-defined use case in particle physics. If you work in HEP or use software that follows CLHEP conventions, this is the standard way to handle units and constants in Python. Even if you only occasionally need HEP unit conversions, the permissive license and lack of dependencies make it a safe, lightweight addition.
Install
hepunits on PyPI
pip
pip install hepunitsuv
uv add hepunitspoetry
poetry add hepunitsInstalling hepunits
Before you install
Low install friction with no runtime dependencies. Active maintenance with a release within the last 59 days. Supports Python 3.9 through 3.14, indicating current compatibility.
License in practice
BSD-3-Clause is a permissive license allowing commercial and private use with minimal restrictions, making this package safe to incorporate into most projects.
Quickstart
pip install hepunits
from hepunits.constants import c_light
from hepunits.units import picosecond, micrometer
tau = 1.5 * picosecond
distance = c_light * tau
print(distance / micrometer) # converts to micrometers
Verify before relying
- Whether Pint integration is required for typical use or remains optional for most workflows
- Performance characteristics when working with large datasets or frequent unit conversions
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 59 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 119,221/month — #12,081 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: hepunits-2.4.6-py3-none-any.whl
Keywords: Constants, HEP, HEP system of units, Units
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
particleProvides a pythonic interface to Particle Data…
permissive · top 15,000 on PyPI
PintPint defines, operates on, and converts between…
permissive · top 5,000 on PyPI
ansys-unitsManages physical quantities with numerical…
permissive · top 15,000 on PyPI
Pint-PandasPint-Pandas adds physical unit support to…
permissive · top 15,000 on PyPI
pint-xarrayAdds physical units support to xarray datasets…
permissive · top 15,000 on PyPI
ucumvertParses UCUM (Unified Code for Units of Measure)…
permissive · top 15,000 on PyPI
uproot3-methodsAdds physics-oriented methods to ROOT file…
permissive · top 15,000 on PyPI
mendeleevProvides a Python API to query properties of…
permissive · top 15,000 on PyPI
mplhepmplhep provides matplotlib styling and helper…
permissive · top 15,000 on PyPI
uprootUproot reads and writes ROOT files (the data…
permissive · top 5,000 on PyPI