There are also methods ‘to_reduced_units’ and ‘ito_reduced_units’ which perform
a simplified dimensional reduction, combining units with the same dimensionality
but otherwise keeping your unit definitions intact.

If you want pint to automatically perform dimensional reduction when producing
new quantities, the UnitRegistry accepts a parameter auto_reduce_dimensions.
Dimensional reduction can be slow, so auto-reducing is disabled by default.

In some cases it is useful to define physical quantities objects using the
class constructor:

>>> Q_=ureg.Quantity>>> Q_(1.78,ureg.meter)==1.78*ureg.meterTrue

(I tend to abbreviate Quantity as Q_) The built-in parser recognizes prefixed
and pluralized units even though they are not in the definition list:

If you use Pint in multiple modules within your Python package, you normally
want to avoid creating multiple instances of the unit registry.
The best way to do this is by instantiating the registry in a single place. For
example, you can add the following code to your package __init__.py:

frompintimportUnitRegistryureg=UnitRegistry()Q_=ureg.Quantity

Then in yourmodule.py the code would be:

from.importureg,Q_length=10*ureg.metermy_speed=Q_(20,'m/s')

If you are pickling and unplicking Quantities within your project, you should
also define the registry as the application registry:

There are no global units in Pint. All units belong to a registry and you can have multiple registries instantiated at the same time. However, you are not supposed to operate between quantities that belong to different registries. Never do things like this: