1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
3 NAMEBASE= python-cachetools
7 SDESC[py38]= Extensible memoizing collections (PY38)
8 SDESC[py39]= Extensible memoizing collections (PY39)
9 HOMEPAGE= https://github.com/tkem/cachetools/
10 CONTACT= Python_Automaton[python@ironwolf.systems]
13 SITES[main]= PYPIWHL/bb/72/8df2e0dc991f1a1d2c6869404e7622e8ee50d80bff357dbb57c3df70305b
14 DISTFILE[1]= cachetools-4.2.1-py3-none-any.whl:main
19 OPTIONS_AVAILABLE= PY38 PY39
20 OPTIONS_STANDARD= none
21 VOPTS[py38]= PY38=ON PY39=OFF
22 VOPTS[py39]= PY38=OFF PY39=ON
24 DISTNAME= cachetools-4.2.1.dist-info
28 [PY38].USES_ON= python:py38,wheel
30 [PY39].USES_ON= python:py39,wheel
32 [FILE:2980:descriptions/desc.single]
34 ========================================================================
36 :alt: Latest PyPI version
38 :alt: Documentation build status
40 :alt: Travis CI build status
44 :alt: Libraries.io SourceRank
48 This module provides various memoizing collections and decorators,
49 including variants of the Python Standard Library's `@lru_cache`_
52 .. code-block:: python
54 from cachetools import cached, LRUCache, TTLCache
56 # speed up calculating Fibonacci numbers with dynamic programming
59 return n if n < 2 else fib(n - 1) + fib(n - 2)
61 # cache least recently used Python Enhancement Proposals
62 @cached(cache=LRUCache(maxsize=32))
64 url = 'http://www.python.org/dev/peps/pep-%04d/' % num
65 with urllib.request.urlopen(url) as s:
68 # cache weather data for no longer than ten minutes
69 @cached(cache=TTLCache(maxsize=1024, ttl=600))
70 def get_weather(place):
71 return owm.weather_at_place(place).get_weather()
73 For the purpose of this module, a *cache* is a mutable_ mapping_ of a
74 fixed maximum size. When the cache is full, i.e. by adding another
75 item the cache would exceed its maximum size, the cache must choose
76 which item(s) to discard based on a suitable `cache algorithm`_. In
77 general, a cache's size is the total size of its items, and an item's
78 size is a property or function of its value, e.g. the result of
79 ``sys.getsizeof(value)``. For the trivial but common case that each
80 item counts as 1, a cache's size is equal to the number of its
81 items, or ``len(cache)``.
83 Multiple cache classes based on different caching algorithms are
84 implemented, and decorators for easily memoizing function and method
85 calls are provided, too.
88 ------------------------------------------------------------------------
90 cachetools is available from PyPI_ and can be installed by running::
92 pip install cachetools
95 ------------------------------------------------------------------------
103 ------------------------------------------------------------------------
105 Copyright (c) 2014-2021 Thomas Kemmer.
107 Licensed under the `MIT License`_.
110 http://docs.python.org/3/library/functools.html#functools.lru_cache
111 .. _mutable: http://docs.python.org/dev/glossary.html#term-mutable
112 .. _mapping: http://docs.python.org/dev/glossary.html#term-mapping
113 .. _cache algorithm: http://en.wikipedia.org/wiki/Cache_algorithms
115 .. _PyPI: https://pypi.org/project/cachetools/
116 .. _Documentation: https://cachetools.readthedocs.io/
117 .. _Issue tracker: https://github.com/tkem/cachetools/issues/
118 .. _Source code: https://github.com/tkem/cachetools/
120 https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst
121 .. _MIT License: http://raw.github.com/tkem/cachetools/master/LICENSE
125 1d9d5f567be80f7c07d765e21b814326d78c61eb0c3a637dffc0e5d1796cb2e2 12003 cachetools-4.2.1-py3-none-any.whl