METADATA 5.3 KB

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