skillfed

hepunits

Units and constants in the HEP system of units

hepunits v2.4.6 119.2K downloads/30d#12,081 on PyPI31
Permissive license BSD-3-Clause Active released

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 hepunits

uv

uv add hepunits

poetry

poetry add hepunits

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Scientific/Engineering

Tags

HEP units constantsparticle physics unitsCLHEP units pythonhigh energy physics unitsMeV GeV keV unitsphysics unit conversionscientific constants HEP
physics-unitsparticle-physicsscientific-computing

More Scientific/Engineering packages