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.
| 430 | _CacheInfo = namedtuple("CacheInfo", ["hits", "misses", "maxsize", "currsize"]) |
| 431 | |
| 432 | class _HashedSeq(list): |
| 433 | """ This class guarantees that hash() will be called no more than once |
| 434 | per element. This is important because the lru_cache() will hash |
| 435 | the key multiple times on a cache miss. |
| 436 | |
| 437 | """ |
| 438 | |
| 439 | __slots__ = 'hashvalue' |
| 440 | |
| 441 | def __init__(self, tup, hash=hash): |
| 442 | self[:] = tup |
| 443 | self.hashvalue = hash(tup) |
| 444 | |
| 445 | def __hash__(self): |
| 446 | return self.hashvalue |
| 447 | |
| 448 | def _make_key(args, kwds, typed, |
| 449 | kwd_mark = (object(),), |