Skip to main content

A list-like structure which implements collections.abc.MutableSequence

Project description

GitHub status for master branch codecov.io status for master branch Latest PyPI package version Latest Read The Docs Discourse group for io-libs Chat on Gitter

Introduction

frozenlist.FrozenList is a list-like structure which implements collections.abc.MutableSequence. The list is mutable until FrozenList.freeze is called, after which list modifications raise RuntimeError:

>>> from frozenlist import FrozenList
>>> fl = FrozenList([17, 42])
>>> fl.append('spam')
>>> fl.append('Vikings')
>>> fl
<FrozenList(frozen=False, [17, 42, 'spam', 'Vikings'])>
>>> fl.freeze()
>>> fl
<FrozenList(frozen=True, [17, 42, 'spam', 'Vikings'])>
>>> fl.frozen
True
>>> fl.append("Monty")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "frozenlist/_frozenlist.pyx", line 97, in frozenlist._frozenlist.FrozenList.append
    self._check_frozen()
  File "frozenlist/_frozenlist.pyx", line 19, in frozenlist._frozenlist.FrozenList._check_frozen
    raise RuntimeError("Cannot modify frozen list.")
RuntimeError: Cannot modify frozen list.

FrozenList is also hashable, but only when frozen. Otherwise it also throws a RuntimeError:

>>> fl = FrozenList([17, 42, 'spam'])
>>> hash(fl)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "frozenlist/_frozenlist.pyx", line 111, in frozenlist._frozenlist.FrozenList.__hash__
    raise RuntimeError("Cannot hash unfrozen list.")
RuntimeError: Cannot hash unfrozen list.
>>> fl.freeze()
>>> hash(fl)
3713081631934410656
>>> dictionary = {fl: 'Vikings'} # frozen fl can be a dict key
>>> dictionary
{<FrozenList(frozen=True, [1, 2])>: 'Vikings'}

Installation

$ pip install frozenlist

The library requires Python 3.6 or newer.

Documentation

https://frozenlist.readthedocs.io/

Communication channels

aio-libs discourse group: https://aio-libs.discourse.group

Feel free to post your questions and ideas here.

gitter chat https://gitter.im/aio-libs/Lobby

Requirements

  • Python >= 3.6

License

frozenlist is offered under the Apache 2 license.

Source code

The project is hosted on GitHub

Please file an issue in the bug tracker if you have found a bug or have some suggestions to improve the library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frozenlist-1.3.1.tar.gz (66.4 kB view hashes)

Uploaded Source

Built Distributions

frozenlist-1.3.1-cp310-cp310-win_amd64.whl (33.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

frozenlist-1.3.1-cp310-cp310-win32.whl (30.6 kB view hashes)

Uploaded CPython 3.10 Windows x86

frozenlist-1.3.1-cp310-cp310-musllinux_1_1_x86_64.whl (152.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

frozenlist-1.3.1-cp310-cp310-musllinux_1_1_s390x.whl (155.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ s390x

frozenlist-1.3.1-cp310-cp310-musllinux_1_1_ppc64le.whl (157.7 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ppc64le

frozenlist-1.3.1-cp310-cp310-musllinux_1_1_i686.whl (145.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

frozenlist-1.3.1-cp310-cp310-musllinux_1_1_aarch64.whl (151.6 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

frozenlist-1.3.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (151.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

frozenlist-1.3.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (155.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

frozenlist-1.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (148.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

frozenlist-1.3.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (149.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

frozenlist-1.3.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (142.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

frozenlist-1.3.1-cp310-cp310-macosx_11_0_arm64.whl (34.5 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

frozenlist-1.3.1-cp310-cp310-macosx_10_9_x86_64.whl (36.0 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

frozenlist-1.3.1-cp310-cp310-macosx_10_9_universal2.whl (61.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

frozenlist-1.3.1-cp39-cp39-win_amd64.whl (34.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

frozenlist-1.3.1-cp39-cp39-win32.whl (31.2 kB view hashes)

Uploaded CPython 3.9 Windows x86

frozenlist-1.3.1-cp39-cp39-musllinux_1_1_x86_64.whl (160.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

frozenlist-1.3.1-cp39-cp39-musllinux_1_1_s390x.whl (165.3 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ s390x

frozenlist-1.3.1-cp39-cp39-musllinux_1_1_ppc64le.whl (167.5 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ppc64le

frozenlist-1.3.1-cp39-cp39-musllinux_1_1_i686.whl (154.7 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

frozenlist-1.3.1-cp39-cp39-musllinux_1_1_aarch64.whl (161.2 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

frozenlist-1.3.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (162.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

frozenlist-1.3.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (166.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

frozenlist-1.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (159.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

frozenlist-1.3.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (158.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

frozenlist-1.3.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (152.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

frozenlist-1.3.1-cp39-cp39-macosx_11_0_arm64.whl (35.3 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

frozenlist-1.3.1-cp39-cp39-macosx_10_9_x86_64.whl (36.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

frozenlist-1.3.1-cp39-cp39-macosx_10_9_universal2.whl (63.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

frozenlist-1.3.1-cp38-cp38-win_amd64.whl (34.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

frozenlist-1.3.1-cp38-cp38-win32.whl (31.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

frozenlist-1.3.1-cp38-cp38-musllinux_1_1_x86_64.whl (167.8 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

frozenlist-1.3.1-cp38-cp38-musllinux_1_1_s390x.whl (173.2 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ s390x

frozenlist-1.3.1-cp38-cp38-musllinux_1_1_ppc64le.whl (175.8 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ppc64le

frozenlist-1.3.1-cp38-cp38-musllinux_1_1_i686.whl (163.0 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

frozenlist-1.3.1-cp38-cp38-musllinux_1_1_aarch64.whl (168.7 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

frozenlist-1.3.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (166.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

frozenlist-1.3.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (169.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

frozenlist-1.3.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (162.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

frozenlist-1.3.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (161.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

frozenlist-1.3.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (156.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

frozenlist-1.3.1-cp38-cp38-macosx_11_0_arm64.whl (35.1 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

frozenlist-1.3.1-cp38-cp38-macosx_10_9_x86_64.whl (36.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

frozenlist-1.3.1-cp38-cp38-macosx_10_9_universal2.whl (62.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

frozenlist-1.3.1-cp37-cp37m-win_amd64.whl (34.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

frozenlist-1.3.1-cp37-cp37m-win32.whl (31.1 kB view hashes)

Uploaded CPython 3.7m Windows x86

frozenlist-1.3.1-cp37-cp37m-musllinux_1_1_x86_64.whl (150.4 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

frozenlist-1.3.1-cp37-cp37m-musllinux_1_1_s390x.whl (156.7 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ s390x

frozenlist-1.3.1-cp37-cp37m-musllinux_1_1_ppc64le.whl (158.9 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ ppc64le

frozenlist-1.3.1-cp37-cp37m-musllinux_1_1_i686.whl (145.4 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

frozenlist-1.3.1-cp37-cp37m-musllinux_1_1_aarch64.whl (149.8 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ ARM64

frozenlist-1.3.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl (153.9 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ s390x

frozenlist-1.3.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (156.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ppc64le

frozenlist-1.3.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (147.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

frozenlist-1.3.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (148.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

frozenlist-1.3.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (142.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

frozenlist-1.3.1-cp37-cp37m-macosx_10_9_x86_64.whl (36.6 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page