summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel B. Mohler <joel@kiwistrawberry.us>2014-08-22 10:04:38 -0400
committerJoel B. Mohler <joel@kiwistrawberry.us>2014-08-22 10:04:38 -0400
commit15d2ff3e2176e45721d2bcb4a7e8bd1d7254efee (patch)
treefe58c4551bc0d6fc2065517ed98935dc24018898
parent05557bc290dbc7a4a62ec521074c8181baa8f844 (diff)
downloadpint-15d2ff3e2176e45721d2bcb4a7e8bd1d7254efee.tar.gz
symbol accessor optimization for string formatting
-rw-r--r--pint/quantity.py2
-rw-r--r--pint/unit.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/pint/quantity.py b/pint/quantity.py
index 9f072b8..4e18f83 100644
--- a/pint/quantity.py
+++ b/pint/quantity.py
@@ -126,7 +126,7 @@ class _Quantity(object):
spec = spec or self.default_format
if '~' in spec:
- units = UnitsContainer(dict((self._REGISTRY.get_symbol(key), value)
+ units = UnitsContainer(dict((self._REGISTRY._get_symbol(key), value)
for key, value in self.units.items()))
spec = spec.replace('~', '')
else:
diff --git a/pint/unit.py b/pint/unit.py
index 0864c4d..95af3be 100644
--- a/pint/unit.py
+++ b/pint/unit.py
@@ -880,6 +880,9 @@ class UnitRegistry(object):
return self._prefixes[prefix].symbol + self._units[unit_name].symbol
+ def _get_symbol(self, name):
+ return self._units[name].symbol
+
def get_dimensionality(self, input_units):
"""Convert unit or dict of units or dimensions to a dict of base dimensions