cachetools 7.2.0__tar.gz → 7.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cachetools-7.2.0 → cachetools-7.2.1}/CHANGELOG.rst +11 -0
- {cachetools-7.2.0/src/cachetools.egg-info → cachetools-7.2.1}/PKG-INFO +1 -1
- {cachetools-7.2.0 → cachetools-7.2.1}/docs/index.rst +3 -2
- {cachetools-7.2.0 → cachetools-7.2.1}/pyproject.toml +0 -3
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/__init__.py +6 -7
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/_cached.py +2 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/_cachedmethod.py +2 -0
- {cachetools-7.2.0 → cachetools-7.2.1/src/cachetools.egg-info}/PKG-INFO +1 -1
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_rr.py +15 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/LICENSE +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/MANIFEST.in +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/README.rst +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/docs/conf.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/setup.cfg +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/__init__.pyi +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/func.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/func.pyi +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/keys.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/keys.pyi +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools/py.typed +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools.egg-info/SOURCES.txt +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools.egg-info/dependency_links.txt +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/src/cachetools.egg-info/top_level.txt +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/__init__.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_cache.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_cached.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_cachedmethod.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_classmethod.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_fifo.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_func.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_keys.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_lfu.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_lru.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_threading.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_tlru.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tests/test_ttl.py +0 -0
- {cachetools-7.2.0 → cachetools-7.2.1}/tox.ini +0 -0
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
v7.2.1 (2026-10-05)
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
- Improve error handling for ``RRCache.popitem()`` when the cache is
|
|
5
|
+
empty.
|
|
6
|
+
|
|
7
|
+
- Minor style and documentation improvements.
|
|
8
|
+
|
|
9
|
+
- Update CI environment.
|
|
10
|
+
|
|
11
|
+
|
|
1
12
|
v7.2.0 (2026-09-16)
|
|
2
13
|
===================
|
|
3
14
|
|
|
@@ -756,8 +756,9 @@ this module provides several memoizing function decorators with a
|
|
|
756
756
|
similar API. All these decorators wrap a function with a memoizing
|
|
757
757
|
callable that saves up to the `maxsize` most recent calls, using
|
|
758
758
|
different caching strategies. If `maxsize` is set to :const:`None`,
|
|
759
|
-
the
|
|
760
|
-
|
|
759
|
+
the size limit is disabled and the cache can grow without bound.
|
|
760
|
+
For :func:`ttl_cache`, the time-to-live still applies, so cached
|
|
761
|
+
results expire after `ttl` even without a size limit.
|
|
761
762
|
|
|
762
763
|
If the optional argument `typed` is set to :const:`True`, function
|
|
763
764
|
arguments of different types will be cached separately. For example,
|
|
@@ -50,9 +50,6 @@ version = {attr = "cachetools.__version__"}
|
|
|
50
50
|
|
|
51
51
|
[tool.pyright]
|
|
52
52
|
typeCheckingMode = "standard"
|
|
53
|
-
reportFunctionMemberAccess = "information"
|
|
54
|
-
reportOptionalContextManager = "warning"
|
|
55
|
-
reportOptionalMemberAccess = "warning"
|
|
56
53
|
|
|
57
54
|
[tool.ruff.lint]
|
|
58
55
|
ignore = ["DTZ005", "UP031"]
|
|
@@ -12,7 +12,7 @@ __all__ = (
|
|
|
12
12
|
"cachedmethod",
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
-
__version__ = "7.2.
|
|
15
|
+
__version__ = "7.2.1"
|
|
16
16
|
|
|
17
17
|
import collections
|
|
18
18
|
import collections.abc
|
|
@@ -52,7 +52,7 @@ class Cache(collections.abc.MutableMapping):
|
|
|
52
52
|
def __init__(self, maxsize, getsizeof=None):
|
|
53
53
|
if maxsize < 0:
|
|
54
54
|
raise ValueError("maxsize must be non-negative")
|
|
55
|
-
if getsizeof:
|
|
55
|
+
if getsizeof is not None:
|
|
56
56
|
self.getsizeof = getsizeof
|
|
57
57
|
if self.getsizeof is not Cache.getsizeof:
|
|
58
58
|
self.__size = {}
|
|
@@ -357,12 +357,11 @@ class RRCache(Cache):
|
|
|
357
357
|
|
|
358
358
|
def popitem(self):
|
|
359
359
|
"""Remove and return a random `(key, value)` pair."""
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
except IndexError:
|
|
360
|
+
keys = self.__keys
|
|
361
|
+
if not keys:
|
|
363
362
|
raise KeyError("%s is empty" % type(self).__name__) from None
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
key = self.__choice(keys)
|
|
364
|
+
return (key, self.pop(key))
|
|
366
365
|
|
|
367
366
|
def clear(self):
|
|
368
367
|
Cache.clear(self)
|
|
@@ -86,3 +86,18 @@ class RRCacheTest(unittest.TestCase, CacheTestMixin):
|
|
|
86
86
|
def test_rr_default_choice(self):
|
|
87
87
|
cache = RRCache[int, int](maxsize=2)
|
|
88
88
|
self.assertIs(cache.choice, random.choice)
|
|
89
|
+
|
|
90
|
+
def test_rr_popitem_empty_custom_choice(self):
|
|
91
|
+
# a custom `choice` function only has to handle non-empty
|
|
92
|
+
# sequences, so an empty cache has to be detected beforehand
|
|
93
|
+
for choice in (min, max, lambda seq: next(iter(seq))):
|
|
94
|
+
cache = RRCache[int, int](maxsize=2, choice=choice)
|
|
95
|
+
|
|
96
|
+
with self.assertRaises(KeyError):
|
|
97
|
+
cache.popitem()
|
|
98
|
+
|
|
99
|
+
cache[1] = 1
|
|
100
|
+
self.assertEqual((1, 1), cache.popitem())
|
|
101
|
+
|
|
102
|
+
with self.assertRaises(KeyError):
|
|
103
|
+
cache.popitem()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|