Bug 1858509 add thread-safety annotations around MediaSourceDemuxer::mMonitor r=alwu
[gecko.git] / third_party / python / frozenlist / README.rst
blob9345fb70632e67db8829640818ab6c8936ecb0d3
1 ==========
2 frozenlist
3 ==========
5 .. image:: https://github.com/aio-libs/frozenlist/workflows/CI/badge.svg
6    :target: https://github.com/aio-libs/frozenlist/actions
7    :alt: GitHub status for master branch
9 .. image:: https://codecov.io/gh/aio-libs/frozenlist/branch/master/graph/badge.svg
10    :target: https://codecov.io/gh/aio-libs/frozenlist
11    :alt: codecov.io status for master branch
13 .. image:: https://badge.fury.io/py/frozenlist.svg
14    :target: https://pypi.org/project/frozenlist
15    :alt: Latest PyPI package version
17 .. image:: https://readthedocs.org/projects/frozenlist/badge/?version=latest
18    :target: https://frozenlist.readthedocs.io/
19    :alt: Latest Read The Docs
21 .. image:: https://img.shields.io/discourse/topics?server=https%3A%2F%2Faio-libs.discourse.group%2F
22    :target: https://aio-libs.discourse.group/
23    :alt: Discourse group for io-libs
25 .. image:: https://badges.gitter.im/Join%20Chat.svg
26    :target: https://gitter.im/aio-libs/Lobby
27    :alt: Chat on Gitter
29 Introduction
30 ============
32 ``frozenlist.FrozenList`` is a list-like structure which implements
33 ``collections.abc.MutableSequence``. The list is *mutable* until ``FrozenList.freeze``
34 is called, after which list modifications raise ``RuntimeError``:
37 >>> from frozenlist import FrozenList
38 >>> fl = FrozenList([17, 42])
39 >>> fl.append('spam')
40 >>> fl.append('Vikings')
41 >>> fl
42 <FrozenList(frozen=False, [17, 42, 'spam', 'Vikings'])>
43 >>> fl.freeze()
44 >>> fl
45 <FrozenList(frozen=True, [17, 42, 'spam', 'Vikings'])>
46 >>> fl.frozen
47 True
48 >>> fl.append("Monty")
49 Traceback (most recent call last):
50   File "<stdin>", line 1, in <module>
51   File "frozenlist/_frozenlist.pyx", line 97, in frozenlist._frozenlist.FrozenList.append
52     self._check_frozen()
53   File "frozenlist/_frozenlist.pyx", line 19, in frozenlist._frozenlist.FrozenList._check_frozen
54     raise RuntimeError("Cannot modify frozen list.")
55 RuntimeError: Cannot modify frozen list.
58 FrozenList is also hashable, but only when frozen. Otherwise it also throws a RuntimeError:
61 >>> fl = FrozenList([17, 42, 'spam'])
62 >>> hash(fl)
63 Traceback (most recent call last):
64   File "<stdin>", line 1, in <module>
65   File "frozenlist/_frozenlist.pyx", line 111, in frozenlist._frozenlist.FrozenList.__hash__
66     raise RuntimeError("Cannot hash unfrozen list.")
67 RuntimeError: Cannot hash unfrozen list.
68 >>> fl.freeze()
69 >>> hash(fl)
70 3713081631934410656
71 >>> dictionary = {fl: 'Vikings'} # frozen fl can be a dict key
72 >>> dictionary
73 {<FrozenList(frozen=True, [1, 2])>: 'Vikings'}
76 Installation
77 ------------
81    $ pip install frozenlist
83 The library requires Python 3.6 or newer.
86 Documentation
87 =============
89 https://frozenlist.readthedocs.io/
91 Communication channels
92 ======================
94 *aio-libs discourse group*: https://aio-libs.discourse.group
96 Feel free to post your questions and ideas here.
98 *gitter chat* https://gitter.im/aio-libs/Lobby
100 Requirements
101 ============
103 - Python >= 3.6
105 License
106 =======
108 ``frozenlist`` is offered under the Apache 2 license.
110 Source code
111 ===========
113 The project is hosted on GitHub_
115 Please file an issue in the `bug tracker
116 <https://github.com/aio-libs/frozenlist/issues>`_ if you have found a bug
117 or have some suggestions to improve the library.
119 .. _GitHub: https://github.com/aio-libs/frozenlist