cachetools 6.2.1__tar.gz → 6.2.2__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.
Files changed (32) hide show
  1. {cachetools-6.2.1 → cachetools-6.2.2}/CHANGELOG.rst +8 -0
  2. {cachetools-6.2.1/src/cachetools.egg-info → cachetools-6.2.2}/PKG-INFO +3 -1
  3. {cachetools-6.2.1 → cachetools-6.2.2}/README.rst +2 -0
  4. {cachetools-6.2.1 → cachetools-6.2.2}/docs/index.rst +2 -2
  5. {cachetools-6.2.1 → cachetools-6.2.2}/src/cachetools/__init__.py +13 -7
  6. {cachetools-6.2.1 → cachetools-6.2.2}/src/cachetools/_cached.py +4 -2
  7. {cachetools-6.2.1 → cachetools-6.2.2}/src/cachetools/keys.py +2 -2
  8. {cachetools-6.2.1 → cachetools-6.2.2/src/cachetools.egg-info}/PKG-INFO +3 -1
  9. {cachetools-6.2.1 → cachetools-6.2.2}/LICENSE +0 -0
  10. {cachetools-6.2.1 → cachetools-6.2.2}/MANIFEST.in +0 -0
  11. {cachetools-6.2.1 → cachetools-6.2.2}/docs/conf.py +0 -0
  12. {cachetools-6.2.1 → cachetools-6.2.2}/pyproject.toml +0 -0
  13. {cachetools-6.2.1 → cachetools-6.2.2}/setup.cfg +0 -0
  14. {cachetools-6.2.1 → cachetools-6.2.2}/setup.py +0 -0
  15. {cachetools-6.2.1 → cachetools-6.2.2}/src/cachetools/_cachedmethod.py +0 -0
  16. {cachetools-6.2.1 → cachetools-6.2.2}/src/cachetools/func.py +0 -0
  17. {cachetools-6.2.1 → cachetools-6.2.2}/src/cachetools.egg-info/SOURCES.txt +0 -0
  18. {cachetools-6.2.1 → cachetools-6.2.2}/src/cachetools.egg-info/dependency_links.txt +0 -0
  19. {cachetools-6.2.1 → cachetools-6.2.2}/src/cachetools.egg-info/top_level.txt +0 -0
  20. {cachetools-6.2.1 → cachetools-6.2.2}/tests/__init__.py +0 -0
  21. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_cache.py +0 -0
  22. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_cached.py +0 -0
  23. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_cachedmethod.py +0 -0
  24. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_fifo.py +0 -0
  25. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_func.py +0 -0
  26. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_keys.py +0 -0
  27. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_lfu.py +0 -0
  28. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_lru.py +0 -0
  29. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_rr.py +0 -0
  30. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_tlru.py +0 -0
  31. {cachetools-6.2.1 → cachetools-6.2.2}/tests/test_ttl.py +0 -0
  32. {cachetools-6.2.1 → cachetools-6.2.2}/tox.ini +0 -0
@@ -1,3 +1,11 @@
1
+ v6.2.2 (2025-11-13)
2
+ ===================
3
+
4
+ - Minor improvements from GitHub Copilot code review.
5
+
6
+ - Improve documentation.
7
+
8
+
1
9
  v6.2.1 (2025-10-12)
2
10
  ===================
3
11
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cachetools
3
- Version: 6.2.1
3
+ Version: 6.2.2
4
4
  Summary: Extensible memoizing collections and decorators
5
5
  Home-page: https://github.com/tkem/cachetools/
6
6
  Author: Thomas Kemmer
@@ -117,6 +117,7 @@ Related Projects
117
117
  ------------------------------------------------------------------------
118
118
 
119
119
  - asyncache_: Helpers to use cachetools_ with asyncio.
120
+ - cachetools-async_: Helpers to use cachetools_ with asyncio.
120
121
  - cacheing_: Pure Python Cacheing Library.
121
122
  - CacheToolsUtils_: Stackable cache classes for sharing, encryption,
122
123
  statistics *and more* on top of cachetools_, redis_ and memcached_.
@@ -146,6 +147,7 @@ Licensed under the `MIT License`_.
146
147
  .. _MIT License: https://raw.github.com/tkem/cachetools/master/LICENSE
147
148
 
148
149
  .. _asyncache: https://pypi.org/project/asyncache/
150
+ .. _cachetools-async: https://pypi.org/project/cachetools-async/
149
151
  .. _cacheing: https://pypi.org/project/cacheing/
150
152
  .. _CacheToolsUtils: https://pypi.org/project/CacheToolsUtils/
151
153
  .. _shelved-cache: https://pypi.org/project/shelved-cache/
@@ -91,6 +91,7 @@ Related Projects
91
91
  ------------------------------------------------------------------------
92
92
 
93
93
  - asyncache_: Helpers to use cachetools_ with asyncio.
94
+ - cachetools-async_: Helpers to use cachetools_ with asyncio.
94
95
  - cacheing_: Pure Python Cacheing Library.
95
96
  - CacheToolsUtils_: Stackable cache classes for sharing, encryption,
96
97
  statistics *and more* on top of cachetools_, redis_ and memcached_.
@@ -120,6 +121,7 @@ Licensed under the `MIT License`_.
120
121
  .. _MIT License: https://raw.github.com/tkem/cachetools/master/LICENSE
121
122
 
122
123
  .. _asyncache: https://pypi.org/project/asyncache/
124
+ .. _cachetools-async: https://pypi.org/project/cachetools-async/
123
125
  .. _cacheing: https://pypi.org/project/cacheing/
124
126
  .. _CacheToolsUtils: https://pypi.org/project/CacheToolsUtils/
125
127
  .. _shelved-cache: https://pypi.org/project/shelved-cache/
@@ -232,7 +232,7 @@ With :class:`TTLCache` and :class:`TLRUCache`, items may also be
232
232
  removed after they expire. In this case, :meth:`popitem` will *not*
233
233
  be called, but :meth:`expire` will be called from the next mutating
234
234
  operation and will return an iterable of the expired `(key, value)`
235
- pairs. By overrding :meth:`expire`, a subclass will be able to track
235
+ pairs. By overriding :meth:`expire`, a subclass will be able to track
236
236
  expired items:
237
237
 
238
238
  .. doctest::
@@ -492,7 +492,7 @@ often called with the same arguments:
492
492
  might expect, and also the use of positional vs. keyword arguments
493
493
  may lead to surprising results. In the example below, `foo()`,
494
494
  `foo(1)` and `foo(a=1)` are treated as different function
495
- invocations, with seperately cached results:
495
+ invocations, with separately cached results:
496
496
 
497
497
  .. doctest::
498
498
  :pyversion: >= 3
@@ -12,7 +12,7 @@ __all__ = (
12
12
  "cachedmethod",
13
13
  )
14
14
 
15
- __version__ = "6.2.1"
15
+ __version__ = "6.2.2"
16
16
 
17
17
  import collections
18
18
  import collections.abc
@@ -27,13 +27,13 @@ from . import keys
27
27
  class _DefaultSize:
28
28
  __slots__ = ()
29
29
 
30
- def __getitem__(self, _):
30
+ def __getitem__(self, _key):
31
31
  return 1
32
32
 
33
- def __setitem__(self, _, value):
34
- assert value == 1
33
+ def __setitem__(self, _key, _value):
34
+ pass
35
35
 
36
- def pop(self, _):
36
+ def pop(self, _key):
37
37
  return 1
38
38
 
39
39
 
@@ -55,7 +55,7 @@ class Cache(collections.abc.MutableMapping):
55
55
 
56
56
  def __repr__(self):
57
57
  return "%s(%s, maxsize=%r, currsize=%r)" % (
58
- self.__class__.__name__,
58
+ type(self).__name__,
59
59
  repr(self.__data),
60
60
  self.__maxsize,
61
61
  self.__currsize,
@@ -100,6 +100,12 @@ class Cache(collections.abc.MutableMapping):
100
100
  def __len__(self):
101
101
  return len(self.__data)
102
102
 
103
+ # Note that we cannot simply inherit get(), pop() and setdefault()
104
+ # from MutableMapping, since these rely on __getitem__ throwing a
105
+ # KeyError on cache miss. This is not the case if __missing__ is
106
+ # implemented for a Cache subclass, so we have to roll our own,
107
+ # somewhat less elegant versions.
108
+
103
109
  def get(self, key, default=None):
104
110
  if key in self:
105
111
  return self[key]
@@ -642,7 +648,7 @@ class TLRUCache(_TimedCache):
642
648
  try:
643
649
  key = next(iter(self.__items))
644
650
  except StopIteration:
645
- raise KeyError("%s is empty" % self.__class__.__name__) from None
651
+ raise KeyError("%s is empty" % type(self).__name__) from None
646
652
  else:
647
653
  return (key, self.pop(key))
648
654
 
@@ -63,7 +63,9 @@ def _locked_info(func, cache, key, lock, info):
63
63
  v = func(*args, **kwargs)
64
64
  with lock:
65
65
  try:
66
- # in case of a race, prefer the item already in the cache
66
+ # In case of a race condition, i.e. if another thread
67
+ # stored a value for this key while we were calling
68
+ # func(), prefer the cached value.
67
69
  return cache.setdefault(k, v)
68
70
  except ValueError:
69
71
  return v # value too large
@@ -173,7 +175,7 @@ def _locked(func, cache, key, lock):
173
175
  v = func(*args, **kwargs)
174
176
  with lock:
175
177
  try:
176
- # in case of a race, prefer the item already in the cache
178
+ # possible race condition: see above
177
179
  return cache.setdefault(k, v)
178
180
  except ValueError:
179
181
  return v # value too large
@@ -29,8 +29,8 @@ class _HashedTuple(tuple):
29
29
  return {}
30
30
 
31
31
 
32
- # used for separating keyword arguments; we do not use an object
33
- # instance here so identity is preserved when pickling/unpickling
32
+ # A sentinel for separating args from kwargs. Using the class itself
33
+ # ensures uniqueness and preserves identity when pickling/unpickling.
34
34
  _kwmark = (_HashedTuple,)
35
35
 
36
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cachetools
3
- Version: 6.2.1
3
+ Version: 6.2.2
4
4
  Summary: Extensible memoizing collections and decorators
5
5
  Home-page: https://github.com/tkem/cachetools/
6
6
  Author: Thomas Kemmer
@@ -117,6 +117,7 @@ Related Projects
117
117
  ------------------------------------------------------------------------
118
118
 
119
119
  - asyncache_: Helpers to use cachetools_ with asyncio.
120
+ - cachetools-async_: Helpers to use cachetools_ with asyncio.
120
121
  - cacheing_: Pure Python Cacheing Library.
121
122
  - CacheToolsUtils_: Stackable cache classes for sharing, encryption,
122
123
  statistics *and more* on top of cachetools_, redis_ and memcached_.
@@ -146,6 +147,7 @@ Licensed under the `MIT License`_.
146
147
  .. _MIT License: https://raw.github.com/tkem/cachetools/master/LICENSE
147
148
 
148
149
  .. _asyncache: https://pypi.org/project/asyncache/
150
+ .. _cachetools-async: https://pypi.org/project/cachetools-async/
149
151
  .. _cacheing: https://pypi.org/project/cacheing/
150
152
  .. _CacheToolsUtils: https://pypi.org/project/CacheToolsUtils/
151
153
  .. _shelved-cache: https://pypi.org/project/shelved-cache/
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