From 829ddd776bd20c081227b9eb9738ae6e00f33014 Mon Sep 17 00:00:00 2001 From: Hernan Grecco Date: Fri, 3 Nov 2023 21:04:06 -0300 Subject: [PATCH] Add cache to _get_root_units --- pint/facets/plain/registry.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pint/facets/plain/registry.py b/pint/facets/plain/registry.py index 4d5cdead0..2e038d4ec 100644 --- a/pint/facets/plain/registry.py +++ b/pint/facets/plain/registry.py @@ -798,6 +798,7 @@ def get_root_units( return f, self.Unit(units) + @methodcache def _get_root_units( self, input_units: UnitsContainer, check_nonmult: bool = True ) -> tuple[Scalar, UnitsContainer]: @@ -824,12 +825,6 @@ def _get_root_units( if not input_units: return 1, self.UnitsContainer() - cache = self._cache.root_units - try: - return cache[input_units] - except KeyError: - pass - accumulators: dict[Optional[str], int] = defaultdict(int) accumulators[None] = 1 self._get_root_units_recurse(input_units, 1, accumulators) @@ -844,7 +839,6 @@ def _get_root_units( if any(not self._units[unit].converter.is_multiplicative for unit in units): factor = None - cache[input_units] = factor, units return factor, units def get_base_units(