diff options
author | Lukas Geiger <lukas.geiger94@gmail.com> | 2025-03-31 14:23:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-31 08:23:41 -0500 |
commit | 0147be09d585e6b5e013ea2d1b24c77500d9a083 (patch) | |
tree | b597075a11ce8ac4b1c8168e92c5c21d0d3ab065 /Lib/functools.py | |
parent | c535a132e40a516a7cca219b2659e85bccaa0529 (diff) | |
download | cpython-0147be09d585e6b5e013ea2d1b24c77500d9a083.tar.gz cpython-0147be09d585e6b5e013ea2d1b24c77500d9a083.zip |
gh-131525: Remove `_HashedSeq` wrapper from `lru_cache` (gh-131922)
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index e0e45bc336c..714070c6ac9 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -516,22 +516,6 @@ def _unwrap_partialmethod(func): _CacheInfo = namedtuple("CacheInfo", ["hits", "misses", "maxsize", "currsize"]) -class _HashedSeq(list): - """ This class guarantees that hash() will be called no more than once - per element. This is important because the lru_cache() will hash - the key multiple times on a cache miss. - - """ - - __slots__ = 'hashvalue' - - def __init__(self, tup, hash=hash): - self[:] = tup - self.hashvalue = hash(tup) - - def __hash__(self): - return self.hashvalue - def _make_key(args, kwds, typed, kwd_mark = (object(),), fasttypes = {int, str}, @@ -561,7 +545,7 @@ def _make_key(args, kwds, typed, key += tuple(type(v) for v in kwds.values()) elif len(key) == 1 and type(key[0]) in fasttypes: return key[0] - return _HashedSeq(key) + return key def lru_cache(maxsize=128, typed=False): """Least-recently-used cache decorator. |