METADATA 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Metadata-Version: 2.1
  2. Name: cachetools
  3. Version: 5.5.0
  4. Summary: Extensible memoizing collections and decorators
  5. Home-page: https://github.com/tkem/cachetools/
  6. Author: Thomas Kemmer
  7. Author-email: tkemmer@computer.org
  8. License: MIT
  9. Classifier: Development Status :: 5 - Production/Stable
  10. Classifier: Environment :: Other Environment
  11. Classifier: Intended Audience :: Developers
  12. Classifier: License :: OSI Approved :: MIT License
  13. Classifier: Operating System :: OS Independent
  14. Classifier: Programming Language :: Python
  15. Classifier: Programming Language :: Python :: 3
  16. Classifier: Programming Language :: Python :: 3.7
  17. Classifier: Programming Language :: Python :: 3.8
  18. Classifier: Programming Language :: Python :: 3.9
  19. Classifier: Programming Language :: Python :: 3.10
  20. Classifier: Programming Language :: Python :: 3.11
  21. Classifier: Programming Language :: Python :: 3.12
  22. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  23. Requires-Python: >=3.7
  24. License-File: LICENSE
  25. cachetools
  26. ========================================================================
  27. .. image:: https://img.shields.io/pypi/v/cachetools
  28. :target: https://pypi.org/project/cachetools/
  29. :alt: Latest PyPI version
  30. .. image:: https://img.shields.io/github/actions/workflow/status/tkem/cachetools/ci.yml
  31. :target: https://github.com/tkem/cachetools/actions/workflows/ci.yml
  32. :alt: CI build status
  33. .. image:: https://img.shields.io/readthedocs/cachetools
  34. :target: https://cachetools.readthedocs.io/
  35. :alt: Documentation build status
  36. .. image:: https://img.shields.io/codecov/c/github/tkem/cachetools/master.svg
  37. :target: https://codecov.io/gh/tkem/cachetools
  38. :alt: Test coverage
  39. .. image:: https://img.shields.io/librariesio/sourcerank/pypi/cachetools
  40. :target: https://libraries.io/pypi/cachetools
  41. :alt: Libraries.io SourceRank
  42. .. image:: https://img.shields.io/github/license/tkem/cachetools
  43. :target: https://raw.github.com/tkem/cachetools/master/LICENSE
  44. :alt: License
  45. .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  46. :target: https://github.com/psf/black
  47. :alt: Code style: black
  48. This module provides various memoizing collections and decorators,
  49. including variants of the Python Standard Library's `@lru_cache`_
  50. function decorator.
  51. .. code-block:: python
  52. from cachetools import cached, LRUCache, TTLCache
  53. # speed up calculating Fibonacci numbers with dynamic programming
  54. @cached(cache={})
  55. def fib(n):
  56. return n if n < 2 else fib(n - 1) + fib(n - 2)
  57. # cache least recently used Python Enhancement Proposals
  58. @cached(cache=LRUCache(maxsize=32))
  59. def get_pep(num):
  60. url = 'http://www.python.org/dev/peps/pep-%04d/' % num
  61. with urllib.request.urlopen(url) as s:
  62. return s.read()
  63. # cache weather data for no longer than ten minutes
  64. @cached(cache=TTLCache(maxsize=1024, ttl=600))
  65. def get_weather(place):
  66. return owm.weather_at_place(place).get_weather()
  67. For the purpose of this module, a *cache* is a mutable_ mapping_ of a
  68. fixed maximum size. When the cache is full, i.e. by adding another
  69. item the cache would exceed its maximum size, the cache must choose
  70. which item(s) to discard based on a suitable `cache algorithm`_.
  71. This module provides multiple cache classes based on different cache
  72. algorithms, as well as decorators for easily memoizing function and
  73. method calls.
  74. Installation
  75. ------------------------------------------------------------------------
  76. cachetools is available from PyPI_ and can be installed by running::
  77. pip install cachetools
  78. Typing stubs for this package are provided by typeshed_ and can be
  79. installed by running::
  80. pip install types-cachetools
  81. Project Resources
  82. ------------------------------------------------------------------------
  83. - `Documentation`_
  84. - `Issue tracker`_
  85. - `Source code`_
  86. - `Change log`_
  87. Related Projects
  88. ------------------------------------------------------------------------
  89. - asyncache_: Helpers to use cachetools with async functions
  90. - cacheing_: Pure Python Cacheing Library
  91. - CacheToolsUtils_: Cachetools Utilities
  92. - kids.cache_: Kids caching library
  93. - shelved-cache_: Persistent cache for Python cachetools
  94. License
  95. ------------------------------------------------------------------------
  96. Copyright (c) 2014-2024 Thomas Kemmer.
  97. Licensed under the `MIT License`_.
  98. .. _@lru_cache: https://docs.python.org/3/library/functools.html#functools.lru_cache
  99. .. _mutable: https://docs.python.org/dev/glossary.html#term-mutable
  100. .. _mapping: https://docs.python.org/dev/glossary.html#term-mapping
  101. .. _cache algorithm: https://en.wikipedia.org/wiki/Cache_algorithms
  102. .. _PyPI: https://pypi.org/project/cachetools/
  103. .. _typeshed: https://github.com/python/typeshed/
  104. .. _Documentation: https://cachetools.readthedocs.io/
  105. .. _Issue tracker: https://github.com/tkem/cachetools/issues/
  106. .. _Source code: https://github.com/tkem/cachetools/
  107. .. _Change log: https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst
  108. .. _MIT License: https://raw.github.com/tkem/cachetools/master/LICENSE
  109. .. _asyncache: https://pypi.org/project/asyncache/
  110. .. _cacheing: https://github.com/breid48/cacheing
  111. .. _CacheToolsUtils: https://pypi.org/project/CacheToolsUtils/
  112. .. _kids.cache: https://pypi.org/project/kids.cache/
  113. .. _shelved-cache: https://pypi.org/project/shelved-cache/