METADATA 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Metadata-Version: 2.1
  2. Name: frozenlist
  3. Version: 1.4.0
  4. Summary: A list-like structure which implements collections.abc.MutableSequence
  5. Home-page: https://github.com/aio-libs/frozenlist
  6. Maintainer: aiohttp team <team@aiohttp.org>
  7. Maintainer-email: team@aiohttp.org
  8. License: Apache 2
  9. Project-URL: Chat: Matrix, https://matrix.to/#/#aio-libs:matrix.org
  10. Project-URL: Chat: Matrix Space, https://matrix.to/#/#aio-libs-space:matrix.org
  11. Project-URL: CI: Github Actions, https://github.com/aio-libs/frozenlist/actions
  12. Project-URL: Code of Conduct, https://github.com/aio-libs/.github/blob/master/CODE_OF_CONDUCT.md
  13. Project-URL: Coverage: codecov, https://codecov.io/github/aio-libs/frozenlist
  14. Project-URL: Docs: Changelog, https://github.com/aio-libs/frozenlist/blob/master/CHANGES.rst#changelog
  15. Project-URL: Docs: RTD, https://frozenlist.aio-libs.org
  16. Project-URL: GitHub: issues, https://github.com/aio-libs/frozenlist/issues
  17. Project-URL: GitHub: repo, https://github.com/aio-libs/frozenlist
  18. Classifier: License :: OSI Approved :: Apache Software License
  19. Classifier: Intended Audience :: Developers
  20. Classifier: Programming Language :: Python
  21. Classifier: Programming Language :: Python :: 3
  22. Classifier: Programming Language :: Python :: 3.8
  23. Classifier: Programming Language :: Python :: 3.9
  24. Classifier: Programming Language :: Python :: 3.10
  25. Classifier: Programming Language :: Python :: 3.11
  26. Classifier: Development Status :: 5 - Production/Stable
  27. Classifier: Operating System :: POSIX
  28. Classifier: Operating System :: MacOS :: MacOS X
  29. Classifier: Operating System :: Microsoft :: Windows
  30. Requires-Python: >=3.8
  31. Description-Content-Type: text/x-rst
  32. License-File: LICENSE
  33. ==========
  34. frozenlist
  35. ==========
  36. .. image:: https://github.com/aio-libs/frozenlist/workflows/CI/badge.svg
  37. :target: https://github.com/aio-libs/frozenlist/actions
  38. :alt: GitHub status for master branch
  39. .. image:: https://codecov.io/gh/aio-libs/frozenlist/branch/master/graph/badge.svg
  40. :target: https://codecov.io/gh/aio-libs/frozenlist
  41. :alt: codecov.io status for master branch
  42. .. image:: https://img.shields.io/pypi/v/frozenlist.svg?logo=Python&logoColor=white
  43. :target: https://pypi.org/project/frozenlist
  44. :alt: frozenlist @ PyPI
  45. .. image:: https://readthedocs.org/projects/frozenlist/badge/?version=latest
  46. :target: https://frozenlist.aio-libs.org
  47. :alt: Read The Docs build status badge
  48. .. image:: https://img.shields.io/matrix/aio-libs:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat
  49. :target: https://matrix.to/#/%23aio-libs:matrix.org
  50. :alt: Matrix Room — #aio-libs:matrix.org
  51. .. image:: https://img.shields.io/matrix/aio-libs-space:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs-space%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat
  52. :target: https://matrix.to/#/%23aio-libs-space:matrix.org
  53. :alt: Matrix Space — #aio-libs-space:matrix.org
  54. Introduction
  55. ============
  56. ``frozenlist.FrozenList`` is a list-like structure which implements
  57. ``collections.abc.MutableSequence``. The list is *mutable* until ``FrozenList.freeze``
  58. is called, after which list modifications raise ``RuntimeError``:
  59. >>> from frozenlist import FrozenList
  60. >>> fl = FrozenList([17, 42])
  61. >>> fl.append('spam')
  62. >>> fl.append('Vikings')
  63. >>> fl
  64. <FrozenList(frozen=False, [17, 42, 'spam', 'Vikings'])>
  65. >>> fl.freeze()
  66. >>> fl
  67. <FrozenList(frozen=True, [17, 42, 'spam', 'Vikings'])>
  68. >>> fl.frozen
  69. True
  70. >>> fl.append("Monty")
  71. Traceback (most recent call last):
  72. File "<stdin>", line 1, in <module>
  73. File "frozenlist/_frozenlist.pyx", line 97, in frozenlist._frozenlist.FrozenList.append
  74. self._check_frozen()
  75. File "frozenlist/_frozenlist.pyx", line 19, in frozenlist._frozenlist.FrozenList._check_frozen
  76. raise RuntimeError("Cannot modify frozen list.")
  77. RuntimeError: Cannot modify frozen list.
  78. FrozenList is also hashable, but only when frozen. Otherwise it also throws a RuntimeError:
  79. >>> fl = FrozenList([17, 42, 'spam'])
  80. >>> hash(fl)
  81. Traceback (most recent call last):
  82. File "<stdin>", line 1, in <module>
  83. File "frozenlist/_frozenlist.pyx", line 111, in frozenlist._frozenlist.FrozenList.__hash__
  84. raise RuntimeError("Cannot hash unfrozen list.")
  85. RuntimeError: Cannot hash unfrozen list.
  86. >>> fl.freeze()
  87. >>> hash(fl)
  88. 3713081631934410656
  89. >>> dictionary = {fl: 'Vikings'} # frozen fl can be a dict key
  90. >>> dictionary
  91. {<FrozenList(frozen=True, [1, 2])>: 'Vikings'}
  92. Installation
  93. ------------
  94. ::
  95. $ pip install frozenlist
  96. The library requires Python 3.8 or newer.
  97. Documentation
  98. =============
  99. https://frozenlist.aio-libs.org
  100. Communication channels
  101. ======================
  102. We have a *Matrix Space* `#aio-libs-space:matrix.org
  103. <https://matrix.to/#/%23aio-libs-space:matrix.org>`_ which is
  104. also accessible via Gitter.
  105. Requirements
  106. ============
  107. - Python >= 3.8
  108. License
  109. =======
  110. ``frozenlist`` is offered under the Apache 2 license.
  111. Source code
  112. ===========
  113. The project is hosted on GitHub_
  114. Please file an issue in the `bug tracker
  115. <https://github.com/aio-libs/frozenlist/issues>`_ if you have found a bug
  116. or have some suggestions to improve the library.
  117. .. _GitHub: https://github.com/aio-libs/frozenlist