frozenlist
A list-like structure which implements collections.abc.MutableSequence
Downloads: 0 (30 days)
Description
frozenlist
==========
.. image:: https://github.com/aio-libs/frozenlist/workflows/CI/badge.svg
:target: https://github.com/aio-libs/frozenlist/actions
:alt: GitHub status for master branch
.. image:: https://codecov.io/gh/aio-libs/frozenlist/branch/master/graph/badge.svg?flag=pytest
:target: https://codecov.io/gh/aio-libs/frozenlist?flags[]=pytest
:alt: codecov.io status for master branch
.. image:: https://img.shields.io/pypi/v/frozenlist.svg?logo=Python&logoColor=white
:target: https://pypi.org/project/frozenlist
:alt: frozenlist @ PyPI
.. image:: https://readthedocs.org/projects/frozenlist/badge/?version=latest
:target: https://frozenlist.aio-libs.org
:alt: Read The Docs build status badge
.. 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
:target: https://matrix.to/#/%23aio-libs:matrix.org
:alt: Matrix Room — #aio-libs:matrix.org
.. 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
:target: https://matrix.to/#/%23aio-libs-space:matrix.org
:alt: Matrix Space — #aio-libs-space:matrix.org
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
Documentation
-------------
https://frozenlist.aio-libs.org
Communication channels
----------------------
We have a *Matrix Space* `#aio-libs-space:matrix.org
<https://matrix.to/#/%23aio-libs-space:matrix.org>`_ which is
also accessible via Gitter.
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
<https://github.com/aio-libs/frozenlist/issues>`_ if you have found a bug
or have some suggestions to improve the library.
.. _GitHub: https://github.com/aio-libs/frozenlist
=========
Changelog
=========
..
You should *NOT* be adding new change log entries to this file, this
file is managed by towncrier. You *may* edit previous change logs to
fix problems like typo corrections or such.
To add a new change log entry, please see
https://pip.pypa.io/en/latest/development/contributing/#news-entries
we named the news folder "changes".
WARNING: Don't drop the next directive!
.. towncrier release notes start
v1.8.0
======
*(2025-10-05)*
Contributor-facing changes
--------------------------
- The ``reusable-cibuildwheel.yml`` workflow has been refactored to
be more generic and ``ci-cd.yml`` now holds all the configuration
toggles -- by `@webknjaz <https://github.com/sponsors/webknjaz>`__.
*Related issues and pull requests on GitHub:*
`#668 <https://github.com/aio-libs/frozenlist/issues/668>`__.
- When building wheels, the source distribution is now passed directly
to the ``cibuildwheel`` invocation -- by `@webknjaz <https://github.com/sponsors/webknjaz>`__.
*Related issues and pull requests on GitHub:*
`#669 <https://github.com/aio-libs/frozenlist/issues/669>`__.
- Builds and tests have been added to
``ci-cd.yml`` for arm64 Windows wheels -- by `@finnagin <https://github.com/sponsors/finnagin>`__.
*Related issues and pull requests on GitHub:*
`#677 <https://github.com/aio-libs/frozenlist/issues/677>`__.
- Started building wheels for CPython 3.14 -- by `@kumaraditya303 <https://github.com/sponsors/kumaraditya303>`__.
*Related issues and pull requests on GitHub:*
`#681 <https://github.com/aio-libs/frozenlist/issues/681>`__, `#682 <https://github.com/aio-libs/frozenlist/issues/682>`__.
- Removed ``--config-settings=pure-python=false`` from ``requirements/dev.txt``.
Developers on CPython still get accelerated builds by default. To explicitly build
a pure Python wheel, use ``pip install -e . --config-settings=pure-python=true``
-- by `@bdraco <https://github.com/sponsors/bdraco>`__.
*Related issues and pull requests on GitHub:*
`#687 <https://github.com/aio-libs/frozenlist/issues/687>`__.
----
v1.7.0
======
*(2025-06-09)*
Features
--------
- Added deepcopy support to FrozenList -- by `@bdraco <https://github.com/sponsors/bdraco>`__.
*Related issues and pull requests on GitHub:*
`#659 <https://github.com/aio-libs/frozenlist/issues/659>`__.
Packaging updates and notes for downstreams
-------------------------------------------
- Fixed an issue where ``frozenlist`` binary wheels would be built with debugging symbols and line tracing enabled, which significantly impacted performance. Line tracing is now disabled by default and can only be enabled explicitly -- by `@bdraco <https://github.com/sponsors/bdraco>`__.
This change ensures that production builds are optimized for performance. Developers who need line tracing for debugging purposes can still enable it by:
1. Setting the ``FROZENLIST_CYTHON_TRACING`` environment variable
2. Using the ``--config-setting=with-cython-tracing=true`` option with pip
*Related issues and pull requests on GitHub:*
`#660 <https://github.com/aio-libs/frozenlist/issues/660>`__.
- Enabled ``PIP_CONSTRAINT`` environment variable in the build configuration to ensure the pinned Cython version from ``requirements/cython.txt`` is used during wheel builds.
*Related issues and pull requests on GitHub:*
`#661 <https://github.com/aio-libs/frozenlist/issues/661>`__.
----
v1.6.2
======
*(2025-06-03)*
No significant changes.
----
v1.6.1
======
*(2025-06-02)*
Bug fixes
---------
- Correctly use ``cimport`` for including ``PyBool_FromLong`` -- by `@lysnikolaou <https://github.com/sponsors/lysnikolaou>`__.
*Related issues and pull requests on GitHub:*
`#653 <https://github.com/aio-libs/frozenlist/issues/653>`__.
Packaging updates and notes for downstreams
-------------------------------------------
- Exclude ``_frozenlist.cpp`` from bdists/wheels -- by `@musicinmybrain <https://github.com/sponsors/musicinmybrain>`__.
*Related issues and pull requests on GitHub:*
`#649 <https://github.com/aio-libs/frozenlist/issues/649>`__.
- Updated to use Cython 3.1 universally across the build path -- by `@lysnikolaou <https://github.com/sponsors/lysnikolaou>`__.
*Related issues and pull requests on GitHub:*
`#654 <https://github.com/aio-libs/frozenlist/issues/654>`__.
----
v1.6.0
======
*(2025-04-17)*
Bug fixes
---------
- Stopped implicitly allowing the use of Cython pre-release versions when
building the distribution package -- by `@ajsanchezsanz <https://github.com/sponsors/ajsanchezsanz>`__ and
`@markgreene74 <https://github.com/sponsors/markgreene74>`__.
*Related commits on GitHub:*
`41591f2 <https://github.com/aio-libs/frozenlist/commit/41591f2>`__.
Features
--------
- Implemented support for the free-threaded build of CPython 3.13 -- by `@lysnikolaou <https://github.com/sponsors/lysnikolaou>`__.
*Related issues and pull requests on GitHub:*
`#618 <https://github.com/aio-libs/frozenlist/issues/618>`__.
- Started building armv7l wheels -- by `@bdraco <https://github.com/sponsors/bdraco>`__.
*Related issues and pull requests on GitHub:*
`#642 <https://github.com/aio-libs/frozenlist/issues/642>`__.
Packaging updates and notes for downstreams
-------------------------------------------
- Stopped implicitly allowing the use of Cython pre-release versions when
building the distribution package -- by `@ajsanchezsanz <https://github.com/sponsors/ajsanchezsanz>`__ and
`@markgreene74 <https://github.com/sponsors/markgreene74>`__.
*Related commits on GitHub:*
`41591f2 <https://github.com/aio-libs/frozenlist/commit/41591f2>`__.
- Started building wheels for the free-threaded build of CPython 3.13 -- by `@lysnikolaou <https://github.com/sponsors/lysnikolaou>`__.
*Related issues and pull requests on GitHub:*
`#618 <https://github.com/aio-libs/frozenlist/issues/618>`__.
- The packaging metadata switched to including an SPDX license identifier introduced in `PEP 639 <https://peps.python.org/pep-639>`__ -- by `@cdce8p <https://github.com/sponsors/cdce8p>`__.
*Related issues and pull requests on GitHub:*
`#639 <https://github.com/aio-libs/frozenlist/issues/639>`__.
Contributor-facing changes
--------------------------
- GitHub Actions CI/CD is now configured to manage caching pip-ecosystem
dependencies using `re-actors/cache-python-deps`_ -- an action by
`@webknjaz <https://github.com/sponsors/webknjaz>`__ t