Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-cachetools for 
openSUSE:Factory checked in at 2025-02-25 16:39:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-cachetools (Old)
 and      /work/SRC/openSUSE:Factory/.python-cachetools.new.1873 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-cachetools"

Tue Feb 25 16:39:13 2025 rev:24 rq:1248023 version:5.5.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-cachetools/python-cachetools.changes      
2025-01-29 16:10:01.422582466 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-cachetools.new.1873/python-cachetools.changes
    2025-02-25 16:39:30.430654955 +0100
@@ -1,0 +2,8 @@
+Mon Feb 24 08:18:44 UTC 2025 - John Paul Adrian Glaubitz 
<[email protected]>
+
+- Update to 5.5.2
+  * Reduce number of ``@cached`` lock/unlock operations.
+  * Improve documentation.
+  * Update CI environment.
+
+-------------------------------------------------------------------

Old:
----
  cachetools-5.5.1.tar.gz

New:
----
  cachetools-5.5.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-cachetools.spec ++++++
--- /var/tmp/diff_new_pack.7aFEGk/_old  2025-02-25 16:39:31.354693560 +0100
+++ /var/tmp/diff_new_pack.7aFEGk/_new  2025-02-25 16:39:31.358693727 +0100
@@ -18,7 +18,7 @@
 
 %{?sle15_python_module_pythons}
 Name:           python-cachetools
-Version:        5.5.1
+Version:        5.5.2
 Release:        0
 Summary:        Extensible memoizing collections and decorators
 License:        MIT

++++++ cachetools-5.5.1.tar.gz -> cachetools-5.5.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/CHANGELOG.rst 
new/cachetools-5.5.2/CHANGELOG.rst
--- old/cachetools-5.5.1/CHANGELOG.rst  2025-01-21 22:25:14.000000000 +0100
+++ new/cachetools-5.5.2/CHANGELOG.rst  2025-02-20 21:59:24.000000000 +0100
@@ -1,3 +1,13 @@
+v5.5.2 (2025-02-20)
+===================
+
+- Reduce number of ``@cached`` lock/unlock operations.
+
+- Improve documentation.
+
+- Update CI environment.
+
+
 v5.5.1 (2025-01-21)
 ===================
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/LICENSE new/cachetools-5.5.2/LICENSE
--- old/cachetools-5.5.1/LICENSE        2024-02-26 21:00:26.000000000 +0100
+++ new/cachetools-5.5.2/LICENSE        2025-02-20 21:59:24.000000000 +0100
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2014-2024 Thomas Kemmer
+Copyright (c) 2014-2025 Thomas Kemmer
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of
 this software and associated documentation files (the "Software"), to deal in
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/PKG-INFO 
new/cachetools-5.5.2/PKG-INFO
--- old/cachetools-5.5.1/PKG-INFO       2025-01-21 22:27:04.509996200 +0100
+++ new/cachetools-5.5.2/PKG-INFO       2025-02-20 22:01:02.189478000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.2
 Name: cachetools
-Version: 5.5.1
+Version: 5.5.2
 Summary: Extensible memoizing collections and decorators
 Home-page: https://github.com/tkem/cachetools/
 Author: Thomas Kemmer
@@ -126,7 +126,7 @@
 License
 ------------------------------------------------------------------------
 
-Copyright (c) 2014-2024 Thomas Kemmer.
+Copyright (c) 2014-2025 Thomas Kemmer.
 
 Licensed under the `MIT License`_.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/README.rst 
new/cachetools-5.5.2/README.rst
--- old/cachetools-5.5.1/README.rst     2024-02-26 21:02:36.000000000 +0100
+++ new/cachetools-5.5.2/README.rst     2025-02-20 21:59:24.000000000 +0100
@@ -100,7 +100,7 @@
 License
 ------------------------------------------------------------------------
 
-Copyright (c) 2014-2024 Thomas Kemmer.
+Copyright (c) 2014-2025 Thomas Kemmer.
 
 Licensed under the `MIT License`_.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/docs/conf.py 
new/cachetools-5.5.2/docs/conf.py
--- old/cachetools-5.5.1/docs/conf.py   2024-05-28 18:45:03.000000000 +0200
+++ new/cachetools-5.5.2/docs/conf.py   2025-02-20 21:59:24.000000000 +0100
@@ -19,7 +19,7 @@
 
 
 project = "cachetools"
-copyright = "2014-2024 Thomas Kemmer"
+copyright = "2014-2025 Thomas Kemmer"
 release, version = get_version()
 
 extensions = [
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/docs/index.rst 
new/cachetools-5.5.2/docs/index.rst
--- old/cachetools-5.5.1/docs/index.rst 2025-01-21 22:22:49.000000000 +0100
+++ new/cachetools-5.5.2/docs/index.rst 2025-02-20 21:59:24.000000000 +0100
@@ -41,6 +41,12 @@
 :meth:`self.popitem()` repeatedly until there is enough room for the
 item to be added.
 
+.. note::
+
+   Please be aware that `maxsize` must be a positive number.  If you
+   really want your cache to grow without bounds, use
+   :const:`math.inf` or something similar.
+
 In general, a cache's size is the total size of its item's values.
 Therefore, :class:`Cache` provides a :meth:`getsizeof` method, which
 returns the size of a given `value`.  The default implementation of
@@ -50,12 +56,12 @@
 named constructor parameter `getsizeof`, which may specify a function
 of one argument used to retrieve the size of an item's value.
 
-Note that the values of a :class:`Cache` are mutable by default, as
-are e.g. the values of a :class:`dict`.  It is the user's
-responsibility to take care that cached values are not accidentally
-modified.  This is especially important when using a custom
-`getsizeof` function, since the size of an item's value will only be
-computed when the item is inserted into the cache.
+The values of a :class:`Cache` are mutable by default, as are e.g. the
+values of a :class:`dict`.  It is the user's responsibility to take
+care that cached values are not accidentally modified.  This is
+especially important when using a custom `getsizeof` function, since
+the size of an item's value will only be computed when the item is
+inserted into the cache.
 
 .. note::
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/src/cachetools/__init__.py 
new/cachetools-5.5.2/src/cachetools/__init__.py
--- old/cachetools-5.5.1/src/cachetools/__init__.py     2025-01-21 
22:25:14.000000000 +0100
+++ new/cachetools-5.5.2/src/cachetools/__init__.py     2025-02-20 
21:59:24.000000000 +0100
@@ -13,7 +13,7 @@
     "cachedmethod",
 )
 
-__version__ = "5.5.1"
+__version__ = "5.5.2"
 
 import collections
 import collections.abc
@@ -23,6 +23,7 @@
 import time
 
 from . import keys
+from ._decorators import _cached_wrapper
 
 
 class _DefaultSize:
@@ -643,150 +644,28 @@
 
     def decorator(func):
         if info:
-            hits = misses = 0
-
             if isinstance(cache, Cache):
 
-                def getinfo():
-                    nonlocal hits, misses
+                def make_info(hits, misses):
                     return _CacheInfo(hits, misses, cache.maxsize, 
cache.currsize)
 
             elif isinstance(cache, collections.abc.Mapping):
 
-                def getinfo():
-                    nonlocal hits, misses
+                def make_info(hits, misses):
                     return _CacheInfo(hits, misses, None, len(cache))
 
             else:
 
-                def getinfo():
-                    nonlocal hits, misses
+                def make_info(hits, misses):
                     return _CacheInfo(hits, misses, 0, 0)
 
-            if cache is None:
-
-                def wrapper(*args, **kwargs):
-                    nonlocal misses
-                    misses += 1
-                    return func(*args, **kwargs)
-
-                def cache_clear():
-                    nonlocal hits, misses
-                    hits = misses = 0
-
-                cache_info = getinfo
-
-            elif lock is None:
-
-                def wrapper(*args, **kwargs):
-                    nonlocal hits, misses
-                    k = key(*args, **kwargs)
-                    try:
-                        result = cache[k]
-                        hits += 1
-                        return result
-                    except KeyError:
-                        misses += 1
-                    v = func(*args, **kwargs)
-                    try:
-                        cache[k] = v
-                    except ValueError:
-                        pass  # value too large
-                    return v
-
-                def cache_clear():
-                    nonlocal hits, misses
-                    cache.clear()
-                    hits = misses = 0
-
-                cache_info = getinfo
-
-            else:
-
-                def wrapper(*args, **kwargs):
-                    nonlocal hits, misses
-                    k = key(*args, **kwargs)
-                    try:
-                        with lock:
-                            result = cache[k]
-                            hits += 1
-                            return result
-                    except KeyError:
-                        with lock:
-                            misses += 1
-                    v = func(*args, **kwargs)
-                    # in case of a race, prefer the item already in the cache
-                    try:
-                        with lock:
-                            return cache.setdefault(k, v)
-                    except ValueError:
-                        return v  # value too large
-
-                def cache_clear():
-                    nonlocal hits, misses
-                    with lock:
-                        cache.clear()
-                        hits = misses = 0
-
-                def cache_info():
-                    with lock:
-                        return getinfo()
-
-        else:
-            if cache is None:
-
-                def wrapper(*args, **kwargs):
-                    return func(*args, **kwargs)
-
-                def cache_clear():
-                    pass
-
-            elif lock is None:
-
-                def wrapper(*args, **kwargs):
-                    k = key(*args, **kwargs)
-                    try:
-                        return cache[k]
-                    except KeyError:
-                        pass  # key not found
-                    v = func(*args, **kwargs)
-                    try:
-                        cache[k] = v
-                    except ValueError:
-                        pass  # value too large
-                    return v
-
-                def cache_clear():
-                    cache.clear()
-
-            else:
-
-                def wrapper(*args, **kwargs):
-                    k = key(*args, **kwargs)
-                    try:
-                        with lock:
-                            return cache[k]
-                    except KeyError:
-                        pass  # key not found
-                    v = func(*args, **kwargs)
-                    # in case of a race, prefer the item already in the cache
-                    try:
-                        with lock:
-                            return cache.setdefault(k, v)
-                    except ValueError:
-                        return v  # value too large
-
-                def cache_clear():
-                    with lock:
-                        cache.clear()
-
-            cache_info = None
+            wrapper = _cached_wrapper(func, cache, key, lock, make_info)
+        else:
+            wrapper = _cached_wrapper(func, cache, key, lock, None)
 
         wrapper.cache = cache
         wrapper.cache_key = key
         wrapper.cache_lock = lock
-        wrapper.cache_clear = cache_clear
-        wrapper.cache_info = cache_info
 
         return functools.update_wrapper(wrapper, func)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/src/cachetools/_decorators.py 
new/cachetools-5.5.2/src/cachetools/_decorators.py
--- old/cachetools-5.5.1/src/cachetools/_decorators.py  1970-01-01 
01:00:00.000000000 +0100
+++ new/cachetools-5.5.2/src/cachetools/_decorators.py  2025-02-20 
21:59:53.000000000 +0100
@@ -0,0 +1,152 @@
+"""Extensible memoizing decorator helpers."""
+
+
+def _cached_locked_info(func, cache, key, lock, info):
+    hits = misses = 0
+
+    def wrapper(*args, **kwargs):
+        nonlocal hits, misses
+        k = key(*args, **kwargs)
+        with lock:
+            try:
+                result = cache[k]
+                hits += 1
+                return result
+            except KeyError:
+                misses += 1
+        v = func(*args, **kwargs)
+        with lock:
+            try:
+                # in case of a race, prefer the item already in the cache
+                return cache.setdefault(k, v)
+            except ValueError:
+                return v  # value too large
+
+    def cache_clear():
+        nonlocal hits, misses
+        with lock:
+            cache.clear()
+            hits = misses = 0
+
+    def cache_info():
+        with lock:
+            return info(hits, misses)
+
+    wrapper.cache_clear = cache_clear
+    wrapper.cache_info = cache_info
+    return wrapper
+
+
+def _cached_unlocked_info(func, cache, key, info):
+    hits = misses = 0
+
+    def wrapper(*args, **kwargs):
+        nonlocal hits, misses
+        k = key(*args, **kwargs)
+        try:
+            result = cache[k]
+            hits += 1
+            return result
+        except KeyError:
+            misses += 1
+        v = func(*args, **kwargs)
+        try:
+            cache[k] = v
+        except ValueError:
+            pass  # value too large
+        return v
+
+    def cache_clear():
+        nonlocal hits, misses
+        cache.clear()
+        hits = misses = 0
+
+    wrapper.cache_clear = cache_clear
+    wrapper.cache_info = lambda: info(hits, misses)
+    return wrapper
+
+
+def _uncached_info(func, info):
+    misses = 0
+
+    def wrapper(*args, **kwargs):
+        nonlocal misses
+        misses += 1
+        return func(*args, **kwargs)
+
+    def cache_clear():
+        nonlocal misses
+        misses = 0
+
+    wrapper.cache_clear = cache_clear
+    wrapper.cache_info = lambda: info(0, misses)
+    return wrapper
+
+
+def _cached_locked(func, cache, key, lock):
+    def wrapper(*args, **kwargs):
+        k = key(*args, **kwargs)
+        with lock:
+            try:
+                return cache[k]
+            except KeyError:
+                pass  # key not found
+        v = func(*args, **kwargs)
+        with lock:
+            try:
+                # in case of a race, prefer the item already in the cache
+                return cache.setdefault(k, v)
+            except ValueError:
+                return v  # value too large
+
+    def cache_clear():
+        with lock:
+            cache.clear()
+
+    wrapper.cache_clear = cache_clear
+    return wrapper
+
+
+def _cached_unlocked(func, cache, key):
+    def wrapper(*args, **kwargs):
+        k = key(*args, **kwargs)
+        try:
+            return cache[k]
+        except KeyError:
+            pass  # key not found
+        v = func(*args, **kwargs)
+        try:
+            cache[k] = v
+        except ValueError:
+            pass  # value too large
+        return v
+
+    wrapper.cache_clear = lambda: cache.clear()
+    return wrapper
+
+
+def _uncached(func):
+    def wrapper(*args, **kwargs):
+        return func(*args, **kwargs)
+
+    wrapper.cache_clear = lambda: None
+    return wrapper
+
+
+def _cached_wrapper(func, cache, key, lock, info):
+    if info is not None:
+        if cache is None:
+            wrapper = _uncached_info(func, info)
+        elif lock is None:
+            wrapper = _cached_unlocked_info(func, cache, key, info)
+        else:
+            wrapper = _cached_locked_info(func, cache, key, lock, info)
+    else:
+        if cache is None:
+            wrapper = _uncached(func)
+        elif lock is None:
+            wrapper = _cached_unlocked(func, cache, key)
+        else:
+            wrapper = _cached_locked(func, cache, key, lock)
+        wrapper.cache_info = None
+    return wrapper
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/src/cachetools.egg-info/PKG-INFO 
new/cachetools-5.5.2/src/cachetools.egg-info/PKG-INFO
--- old/cachetools-5.5.1/src/cachetools.egg-info/PKG-INFO       2025-01-21 
22:27:04.000000000 +0100
+++ new/cachetools-5.5.2/src/cachetools.egg-info/PKG-INFO       2025-02-20 
22:01:02.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.2
 Name: cachetools
-Version: 5.5.1
+Version: 5.5.2
 Summary: Extensible memoizing collections and decorators
 Home-page: https://github.com/tkem/cachetools/
 Author: Thomas Kemmer
@@ -126,7 +126,7 @@
 License
 ------------------------------------------------------------------------
 
-Copyright (c) 2014-2024 Thomas Kemmer.
+Copyright (c) 2014-2025 Thomas Kemmer.
 
 Licensed under the `MIT License`_.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/src/cachetools.egg-info/SOURCES.txt 
new/cachetools-5.5.2/src/cachetools.egg-info/SOURCES.txt
--- old/cachetools-5.5.1/src/cachetools.egg-info/SOURCES.txt    2025-01-21 
22:27:04.000000000 +0100
+++ new/cachetools-5.5.2/src/cachetools.egg-info/SOURCES.txt    2025-02-20 
22:01:02.000000000 +0100
@@ -9,6 +9,7 @@
 docs/conf.py
 docs/index.rst
 src/cachetools/__init__.py
+src/cachetools/_decorators.py
 src/cachetools/func.py
 src/cachetools/keys.py
 src/cachetools.egg-info/PKG-INFO
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/tests/test_cached.py 
new/cachetools-5.5.2/tests/test_cached.py
--- old/cachetools-5.5.1/tests/test_cached.py   2023-01-22 23:22:12.000000000 
+0100
+++ new/cachetools-5.5.2/tests/test_cached.py   2025-02-20 21:49:22.000000000 
+0100
@@ -164,6 +164,30 @@
         self.assertEqual(len(cache), 0)
         self.assertEqual(wrapper.cache_info(), (0, 0, 2, 0))
 
+    def test_decorator_lock_info(self):
+        cache = self.cache(2)
+        lock = CountedLock()
+        wrapper = cachetools.cached(cache, lock=lock, info=True)(self.func)
+        self.assertEqual(wrapper.cache_info(), (0, 0, 2, 0))
+        self.assertEqual(lock.count, 1)
+        self.assertEqual(wrapper(0), 0)
+        self.assertEqual(lock.count, 3)
+        self.assertEqual(wrapper.cache_info(), (0, 1, 2, 1))
+        self.assertEqual(lock.count, 4)
+        self.assertEqual(wrapper(1), 1)
+        self.assertEqual(lock.count, 6)
+        self.assertEqual(wrapper.cache_info(), (0, 2, 2, 2))
+        self.assertEqual(lock.count, 7)
+        self.assertEqual(wrapper(0), 0)
+        self.assertEqual(lock.count, 8)
+        self.assertEqual(wrapper.cache_info(), (1, 2, 2, 2))
+        self.assertEqual(lock.count, 9)
+        wrapper.cache_clear()
+        self.assertEqual(lock.count, 10)
+        self.assertEqual(len(cache), 0)
+        self.assertEqual(wrapper.cache_info(), (0, 0, 2, 0))
+        self.assertEqual(lock.count, 11)
+
     def test_zero_size_cache_decorator(self):
         cache = self.cache(0)
         wrapper = cachetools.cached(cache)(self.func)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cachetools-5.5.1/tox.ini new/cachetools-5.5.2/tox.ini
--- old/cachetools-5.5.1/tox.ini        2024-07-15 21:06:23.000000000 +0200
+++ new/cachetools-5.5.2/tox.ini        2025-02-20 21:49:22.000000000 +0100
@@ -6,7 +6,7 @@
     pytest
     pytest-cov
 commands =
-    py.test --basetemp={envtmpdir} --cov=cachetools {posargs}
+    py.test --basetemp={envtmpdir} --cov=cachetools --cov-report term-missing 
{posargs}
 
 [testenv:check-manifest]
 deps =

Reply via email to