Hello community,
here is the log from the commit of package python-cachetools for
openSUSE:Factory checked in at 2019-09-23 12:10:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-cachetools (Old)
and /work/SRC/openSUSE:Factory/.python-cachetools.new.7948 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-cachetools"
Mon Sep 23 12:10:05 2019 rev:7 rq:730683 version:3.1.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-cachetools/python-cachetools.changes
2019-02-28 21:44:26.869498339 +0100
+++
/work/SRC/openSUSE:Factory/.python-cachetools.new.7948/python-cachetools.changes
2019-09-23 12:10:07.297878509 +0200
@@ -1,0 +2,7 @@
+Fri Sep 13 11:08:10 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 3.1.1:
+ * Document how to use shared caches with @cachedmethod.
+ * Fix pickling/unpickling of cache keys
+
+-------------------------------------------------------------------
Old:
----
cachetools-3.1.0.tar.gz
New:
----
cachetools-3.1.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-cachetools.spec ++++++
--- /var/tmp/diff_new_pack.ER7FDm/_old 2019-09-23 12:10:07.869878415 +0200
+++ /var/tmp/diff_new_pack.ER7FDm/_new 2019-09-23 12:10:07.869878415 +0200
@@ -17,9 +17,8 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%bcond_without test
Name: python-cachetools
-Version: 3.1.0
+Version: 3.1.1
Release: 0
Summary: Extensible memoizing collections and decorators
License: MIT
@@ -47,10 +46,8 @@
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
-%if %{with test}
%check
%python_exec setup.py test
-%endif
%files %{python_files}
%license LICENSE
++++++ cachetools-3.1.0.tar.gz -> cachetools-3.1.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/cachetools-3.1.0/CHANGES.rst
new/cachetools-3.1.1/CHANGES.rst
--- old/cachetools-3.1.0/CHANGES.rst 2019-01-29 21:33:24.000000000 +0100
+++ new/cachetools-3.1.1/CHANGES.rst 2019-05-23 21:48:40.000000000 +0200
@@ -1,3 +1,11 @@
+v3.1.1 (2019-05-23)
+-------------------
+
+- Document how to use shared caches with ``@cachedmethod``.
+
+- Fix pickling/unpickling of cache keys
+
+
v3.1.0 (2019-01-29)
-------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/cachetools-3.1.0/PKG-INFO
new/cachetools-3.1.1/PKG-INFO
--- old/cachetools-3.1.0/PKG-INFO 2019-01-29 21:46:18.000000000 +0100
+++ new/cachetools-3.1.1/PKG-INFO 2019-05-23 21:50:01.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: cachetools
-Version: 3.1.0
+Version: 3.1.1
Summary: Extensible memoizing collections and decorators
Home-page: https://github.com/tkem/cachetools
Author: Thomas Kemmer
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/cachetools-3.1.0/cachetools/__init__.py
new/cachetools-3.1.1/cachetools/__init__.py
--- old/cachetools-3.1.0/cachetools/__init__.py 2019-01-29 21:31:04.000000000
+0100
+++ new/cachetools-3.1.1/cachetools/__init__.py 2019-05-23 21:48:11.000000000
+0200
@@ -16,7 +16,7 @@
'cached', 'cachedmethod'
)
-__version__ = '3.1.0'
+__version__ = '3.1.1'
if hasattr(functools.update_wrapper(lambda f: f(), lambda: 42), '__wrapped__'):
_update_wrapper = functools.update_wrapper
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/cachetools-3.1.0/cachetools/keys.py
new/cachetools-3.1.1/cachetools/keys.py
--- old/cachetools-3.1.0/cachetools/keys.py 2017-08-11 18:23:50.000000000
+0200
+++ new/cachetools-3.1.1/cachetools/keys.py 2019-05-23 21:48:11.000000000
+0200
@@ -6,6 +6,12 @@
class _HashedTuple(tuple):
+ """A tuple that ensures that hash() will be called no more than once
+ per element, since cache decorators will hash the key multiple
+ times on a cache miss. See also _HashedSeq in the standard
+ library functools implementation.
+
+ """
__hashvalue = None
@@ -21,8 +27,13 @@
def __radd__(self, other, add=tuple.__add__):
return _HashedTuple(add(other, self))
+ def __getstate__(self):
+ return {}
+
-_kwmark = (object(),)
+# used for separating keyword arguments; we do not use an object
+# instance here so identity is preserved when pickling/unpickling
+_kwmark = (_HashedTuple,)
def hashkey(*args, **kwargs):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/cachetools-3.1.0/cachetools.egg-info/PKG-INFO
new/cachetools-3.1.1/cachetools.egg-info/PKG-INFO
--- old/cachetools-3.1.0/cachetools.egg-info/PKG-INFO 2019-01-29
21:46:18.000000000 +0100
+++ new/cachetools-3.1.1/cachetools.egg-info/PKG-INFO 2019-05-23
21:50:01.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: cachetools
-Version: 3.1.0
+Version: 3.1.1
Summary: Extensible memoizing collections and decorators
Home-page: https://github.com/tkem/cachetools
Author: Thomas Kemmer
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/cachetools-3.1.0/docs/index.rst
new/cachetools-3.1.1/docs/index.rst
--- old/cachetools-3.1.0/docs/index.rst 2019-01-29 21:31:04.000000000 +0100
+++ new/cachetools-3.1.1/docs/index.rst 2019-05-23 21:48:11.000000000 +0200
@@ -325,6 +325,44 @@
PEP #1: ...
+ When using a shared cache for multiple methods, be aware that
+ different cache keys must be created for each method even when
+ function arguments are the same, just as with the `@cached`
+ decorator:
+
+ .. testcode::
+
+ class CachedReferences(object):
+
+ def __init__(self, cachesize):
+ self.cache = LRUCache(maxsize=cachesize)
+
+ @cachedmethod(lambda self: self.cache, key=partial(hashkey, 'pep'))
+ def get_pep(self, num):
+ """Retrieve text of a Python Enhancement Proposal"""
+ url = 'http://www.python.org/dev/peps/pep-%04d/' % num
+ with urllib.request.urlopen(url) as s:
+ return s.read()
+
+ @cachedmethod(lambda self: self.cache, key=partial(hashkey, 'rfc'))
+ def get_rfc(self, num):
+ """Retrieve text of an IETF Request for Comments"""
+ url = 'https://tools.ietf.org/rfc/rfc%d.txt' % num
+ with urllib.request.urlopen(url) as s:
+ return s.read()
+
+ docs = CachedReferences(cachesize=100)
+ print("PEP #1: %s" % docs.get_pep(1))
+ print("RFC #1: %s" % docs.get_rfc(1))
+
+ .. testoutput::
+ :hide:
+ :options: +ELLIPSIS
+
+ PEP #1: ...
+ RFC #1: ...
+
+
:mod:`cachetools.keys` --- Key functions for memoizing decorators
============================================================================
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/cachetools-3.1.0/tests/test_keys.py
new/cachetools-3.1.1/tests/test_keys.py
--- old/cachetools-3.1.0/tests/test_keys.py 2016-10-03 14:09:18.000000000
+0200
+++ new/cachetools-3.1.1/tests/test_keys.py 2019-05-23 21:48:11.000000000
+0200
@@ -43,3 +43,16 @@
self.assertIsInstance(key(1, 2, 3) + key(4, 5, 6), type(key()))
self.assertIsInstance(key(1, 2, 3) + (4, 5, 6), type(key()))
self.assertIsInstance((1, 2, 3) + key(4, 5, 6), type(key()))
+
+ def test_pickle(self, key=cachetools.keys.hashkey):
+ import pickle
+
+ for k in [key(), key('abc'), key('abc', 123), key('abc', q='abc')]:
+ # white-box test: assert cached hash value is not pickled
+ self.assertEqual(len(k.__dict__), 0)
+ h = hash(k)
+ self.assertEqual(len(k.__dict__), 1)
+ pickled = pickle.loads(pickle.dumps(k))
+ self.assertEqual(len(pickled.__dict__), 0)
+ self.assertEqual(k, pickled)
+ self.assertEqual(h, hash(pickled))