METADATA 5.0 KB

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