Skip to content

Commit

Permalink
Rely on cached_property to cache values on the instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Sep 13, 2024
1 parent eefac29 commit d34a4b7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions zipp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
for more detail.
"""

import contextlib
import functools
import io
import itertools
import pathlib
Expand Down Expand Up @@ -181,16 +181,18 @@ class FastLookup(CompleteDirs):
"""

def namelist(self):
with contextlib.suppress(AttributeError):
return self.__names
self.__names = super().namelist()
return self.__names
return self._namelist

@functools.cached_property
def _namelist(self):
return super().namelist()

def _name_set(self):
with contextlib.suppress(AttributeError):
return self.__lookup
self.__lookup = super()._name_set()
return self.__lookup
return self._name_set_prop

@functools.cached_property
def _name_set_prop(self):
return super()._name_set()


def _extract_text_encoding(encoding=None, *args, **kwargs):
Expand Down

0 comments on commit d34a4b7

Please sign in to comment.