Debian Codegraph @

debian/control

raw
1 Source: frozenlist
2 Section: python
3 Maintainer: Debian Python Team <[email protected]>
4 Uploaders: Piotr Ożarowski <[email protected]>
5 Build-Depends: debhelper-compat (= 13),
6 dh-sequence-python3,
7 cython3,
8 pybuild-plugin-pyproject,
9 python3-all-dev,
10 python3-expandvars,
11 python3-pytest <!nocheck>,
12 python3-pytest-cov <!nocheck>,
13 python3-setuptools,
14 Standards-Version: 4.7.4
15 Homepage: https://github.com/aio-libs/frozenlist
16 Vcs-Git: https://salsa.debian.org/python-team/packages/frozenlist.git
17 Vcs-Browser: https://salsa.debian.org/python-team/packages/frozenlist
18 Testsuite: autopkgtest-pkg-pybuild
19
20 Package: python3-frozenlist
21 Architecture: any
22 Depends: ${misc:Depends}, ${python3:Depends}, ${shlibs:Depends},
23 Recommends: ${python3:Recommends}
24 Suggests: ${python3:Suggests}
25 Description: list-like structure which implements collections.abc.MutableSequence
26 `frozenlist.FrozenList` is a list-like structure which implements
27 `collections.abc.MutableSequence`. The list is mutable until `FrozenList.freeze`
28 is called, after which list modifications raise `RuntimeError`:
29 .
30 >>> from frozenlist import FrozenList
31 >>> fl = FrozenList([17, 42])
32 >>> fl.append('spam')
33 >>> fl.append('Vikings')
34 >>> fl
35 <FrozenList(frozen=False, [17, 42, 'spam', 'Vikings'])>
36 >>> fl.freeze()
37 >>> fl
38 <FrozenList(frozen=True, [17, 42, 'spam', 'Vikings'])>
39 >>> fl.frozen
40 True
41 >>> fl.append("Monty")
42 Traceback (most recent call last):
43 File "<stdin>", line 1, in <module>
44 File "frozenlist/_frozenlist.pyx", line 97, in frozenlist._frozenlist.FrozenList.append
45 self._check_frozen()
46 File "frozenlist/_frozenlist.pyx", line 19, in frozenlist._frozenlist.FrozenList._check_frozen
47 raise RuntimeError("Cannot modify frozen list.")
48 RuntimeError: Cannot modify frozen list.
49 .
50 FrozenList is also hashable, but only when frozen. Otherwise it also throws a RuntimeError:
51 .
52 >>> fl = FrozenList([17, 42, 'spam'])
53 >>> hash(fl)
54 Traceback (most recent call last):
55 File "<stdin>", line 1, in <module>
56 File "frozenlist/_frozenlist.pyx", line 111, in frozenlist._frozenlist.FrozenList.__hash__
57 raise RuntimeError("Cannot hash unfrozen list.")
58 RuntimeError: Cannot hash unfrozen list.
59 >>> fl.freeze()
60 >>> hash(fl)
61 3713081631934410656
62 >>> dictionary = {fl: 'Vikings'} # frozen fl can be a dict key
63 >>> dictionary
64 {<FrozenList(frozen=True, [1, 2])>: 'Vikings'}