You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.3 KiB

  1. Metadata-Version: 2.1
  2. Name: cachetools
  3. Version: 4.1.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. Platform: UNKNOWN
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: Environment :: Other Environment
  12. Classifier: Intended Audience :: Developers
  13. Classifier: License :: OSI Approved :: MIT License
  14. Classifier: Operating System :: OS Independent
  15. Classifier: Programming Language :: Python
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Programming Language :: Python :: 3.5
  18. Classifier: Programming Language :: Python :: 3.6
  19. Classifier: Programming Language :: Python :: 3.7
  20. Classifier: Programming Language :: Python :: 3.8
  21. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  22. Requires-Python: ~=3.5
  23. cachetools
  24. ========================================================================
  25. .. image:: http://img.shields.io/pypi/v/cachetools
  26. :target: https://pypi.org/project/cachetools/
  27. :alt: Latest PyPI version
  28. .. image:: https://img.shields.io/readthedocs/cachetools
  29. :target: http://cachetools.readthedocs.io/
  30. :alt: Documentation build status
  31. .. image:: http://img.shields.io/travis/tkem/cachetools
  32. :target: https://travis-ci.org/tkem/cachetools/
  33. :alt: Travis CI build status
  34. .. image:: http://img.shields.io/coveralls/tkem/cachetools
  35. :target: https://coveralls.io/r/tkem/cachetools
  36. :alt: Test coverage
  37. .. image:: https://img.shields.io/github/license/tkem/cachetools
  38. :target: http://raw.github.com/tkem/cachetools/master/LICENSE
  39. :alt: License
  40. This module provides various memoizing collections and decorators,
  41. including variants of the Python Standard Library's `@lru_cache`_
  42. function decorator.
  43. .. code-block:: python
  44. from cachetools import cached, LRUCache, TTLCache
  45. # speed up calculating Fibonacci numbers with dynamic programming
  46. @cached(cache={})
  47. def fib(n):
  48. return n if n < 2 else fib(n - 1) + fib(n - 2)
  49. # cache least recently used Python Enhancement Proposals
  50. @cached(cache=LRUCache(maxsize=32))
  51. def get_pep(num):
  52. url = 'http://www.python.org/dev/peps/pep-%04d/' % num
  53. with urllib.request.urlopen(url) as s:
  54. return s.read()
  55. # cache weather data for no longer than ten minutes
  56. @cached(cache=TTLCache(maxsize=1024, ttl=600))
  57. def get_weather(place):
  58. return owm.weather_at_place(place).get_weather()
  59. For the purpose of this module, a *cache* is a mutable_ mapping_ of a
  60. fixed maximum size. When the cache is full, i.e. by adding another
  61. item the cache would exceed its maximum size, the cache must choose
  62. which item(s) to discard based on a suitable `cache algorithm`_. In
  63. general, a cache's size is the total size of its items, and an item's
  64. size is a property or function of its value, e.g. the result of
  65. ``sys.getsizeof(value)``. For the trivial but common case that each
  66. item counts as ``1``, a cache's size is equal to the number of its
  67. items, or ``len(cache)``.
  68. Multiple cache classes based on different caching algorithms are
  69. implemented, and decorators for easily memoizing function and method
  70. calls are provided, too.
  71. Installation
  72. ------------------------------------------------------------------------
  73. cachetools is available from PyPI_ and can be installed by running::
  74. pip install cachetools
  75. Project Resources
  76. ------------------------------------------------------------------------
  77. - `Documentation`_
  78. - `Issue tracker`_
  79. - `Source code`_
  80. - `Change log`_
  81. License
  82. ------------------------------------------------------------------------
  83. Copyright (c) 2014-2020 Thomas Kemmer.
  84. Licensed under the `MIT License`_.
  85. .. _@lru_cache: http://docs.python.org/3/library/functools.html#functools.lru_cache
  86. .. _mutable: http://docs.python.org/dev/glossary.html#term-mutable
  87. .. _mapping: http://docs.python.org/dev/glossary.html#term-mapping
  88. .. _cache algorithm: http://en.wikipedia.org/wiki/Cache_algorithms
  89. .. _PyPI: https://pypi.org/project/cachetools/
  90. .. _Documentation: https://cachetools.readthedocs.io/
  91. .. _Issue tracker: https://github.com/tkem/cachetools/issues/
  92. .. _Source code: https://github.com/tkem/cachetools/
  93. .. _Change log: https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst
  94. .. _MIT License: http://raw.github.com/tkem/cachetools/master/LICENSE