accretive


Nameaccretive JSON
Version 2.1 PyPI version JSON
download
home_pageNone
SummaryAccretive data structures.
upload_time2024-11-20 02:29:52
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseApache-2.0
keywords accretion api dictionary indelibility namespace
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. vim: set fileencoding=utf-8:
.. -*- coding: utf-8 -*-
.. +--------------------------------------------------------------------------+
   |                                                                          |
   | Licensed under the Apache License, Version 2.0 (the "License");          |
   | you may not use this file except in compliance with the License.         |
   | You may obtain a copy of the License at                                  |
   |                                                                          |
   |     http://www.apache.org/licenses/LICENSE-2.0                           |
   |                                                                          |
   | Unless required by applicable law or agreed to in writing, software      |
   | distributed under the License is distributed on an "AS IS" BASIS,        |
   | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
   | See the License for the specific language governing permissions and      |
   | limitations under the License.                                           |
   |                                                                          |
   +--------------------------------------------------------------------------+

*******************************************************************************
                                  accretive
*******************************************************************************

.. image:: https://img.shields.io/pypi/v/accretive
   :alt: Project Version
   :target: https://pypi.org/project/accretive/

.. image:: https://img.shields.io/pypi/status/accretive
   :alt: PyPI - Status
   :target: https://pypi.org/project/accretive/

.. image:: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml/badge.svg?branch=master&event=push
   :alt: Tests Status
   :target: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml

.. image:: https://emcd.github.io/python-accretive/coverage.svg
   :alt: Code Coverage Percentage
   :target: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml

.. image:: https://img.shields.io/pypi/pyversions/accretive
   :alt: Python Versions
   :target: https://pypi.org/project/accretive/

.. image:: https://img.shields.io/pypi/l/accretive
   :alt: Project License
   :target: https://github.com/emcd/python-accretive/blob/master/LICENSE.txt


🔒 A Python library package which provides **accretive data structures** -
collections which can grow but never shrink.


Key Features ⭐
===============================================================================

* 📖 **Accretive Dictionary**: Like a regular `dict
  <https://docs.python.org/3/library/stdtypes.html#dict>`_, but entries cannot
  be modified or removed once added. Also has variants with defaults and
  validation.
* 🗃️ **Accretive Namespace**: Similar to `SimpleNamespace
  <https://docs.python.org/3/library/types.html#types.SimpleNamespace>`_, but
  attributes become immutable after assignment.
* 🧱 **Additional Types**: Classes (including abstract base classes), modules,
  and objects with accretive behavior.
* 🏗️ **Flexible Initialization**: Support for unprotected attributes during
  initialization; useful for compatibility with class decorators, such as
  `dataclasses
  <https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass>`_.


Note on Immutability 📢
===============================================================================

   Enforcement of immutability is quite difficult in Python. While this library
   encourages immutability by default, it can be circumvented by anyone who has
   intermediate knowledge of Python machinery and who is determined to
   circumvent the immutability. Use the library in the spirit of making
   programs safer, but understand that it cannot truly prevent unwanted state
   tampering.


Installation 📦
===============================================================================

::

    pip install accretive


Examples 💡
===============================================================================


Accretive Namespace 🗃️
-------------------------------------------------------------------------------

An accretive namespace, similar to ``types.SimpleNamespace``, is available.
This namespace can be initialized from multiple iterables and from keyword
arguments. (Keyword arguments shown below; see documentation for additional
forms of initialization.)

>>> from accretive import Namespace
>>> ns = Namespace( apples = 12, bananas = 6 )
>>> ns.cherries = 42  # ✅ Allows new attributes.
>>> ns.apples = 14    # ❌ Attempted reassignment raises error.
Traceback (most recent call last):
...
accretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'apples'.
>>> del ns.apples     # ❌ Attempted deletion raises error.
Traceback (most recent call last):
...
accretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'apples'.
>>> ns
accretive.namespaces.Namespace( apples = 12, bananas = 6, cherries = 42 )


Accretive Dictionary 📖
-------------------------------------------------------------------------------

An accretive dictionary, similar to ``dict``, is available. This dictionary can
be initialized from multiple iterables and from keyword arguments. (Keyword
arguments shown below; see documentation for additional forms of
initialization.)

>>> from accretive import Dictionary
>>> dct = Dictionary( apples = 12, bananas = 6 )
>>> dct[ 'cherries' ] = 42  # ✅ Allows new entries.
>>> dct.update( blueberries = 96, strawberries = 24 )
accretive.dictionaries.Dictionary( {'apples': 12, 'bananas': 6, 'cherries': 42, 'blueberries': 96, 'strawberries': 24} )
>>> dct[ 'bananas' ] = 11   # ❌ Attempted alteration raises error.
Traceback (most recent call last):
...
accretive.exceptions.EntryImmutabilityError: Cannot alter or remove existing entry for 'bananas'.
>>> del dct[ 'bananas' ]    # ❌ Attempted removal raises error.
Traceback (most recent call last):
...
accretive.exceptions.EntryImmutabilityError: Cannot alter or remove existing entry for 'bananas'.
>>> dct
accretive.dictionaries.Dictionary( {'apples': 12, 'bananas': 6, 'cherries': 42, 'blueberries': 96, 'strawberries': 24} )


Use Cases 🎯
===============================================================================

* 📝 **Configuration Registries**: Registries which can accumulate entries but
  never remove them, thereby guaranteeing sticky state.
* 🔌 **Plugin Systems**: Register extensions which are then guaranteed to be
  available from the time of registration to the end of the process.
* 🔒 **Immutable Collections**: Many scenarios requiring grow-only collections
  with immutability guarantees.


`More Flair <https://www.imdb.com/title/tt0151804/characters/nm0431918>`_
===============================================================================

.. image:: https://img.shields.io/github/last-commit/emcd/python-accretive
   :alt: GitHub last commit
   :target: https://github.com/emcd/python-accretive

.. image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg
   :alt: Hatch
   :target: https://github.com/pypa/hatch

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit
   :alt: pre-commit
   :target: https://github.com/pre-commit/pre-commit

.. image:: https://img.shields.io/badge/security-bandit-yellow.svg
   :alt: Bandit
   :target: https://github.com/PyCQA/bandit

.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen
   :alt: Pylint
   :target: https://github.com/pylint-dev/pylint

.. image:: https://microsoft.github.io/pyright/img/pyright_badge.svg
   :alt: Pyright
   :target: https://microsoft.github.io/pyright/

.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
   :alt: Ruff
   :target: https://github.com/astral-sh/ruff

.. image:: https://img.shields.io/pypi/implementation/accretive
   :alt: PyPI - Implementation
   :target: https://pypi.org/project/accretive/

.. image:: https://img.shields.io/pypi/wheel/accretive
   :alt: PyPI - Wheel
   :target: https://pypi.org/project/accretive/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "accretive",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "accretion, api, dictionary, indelibility, namespace",
    "author": null,
    "author_email": "Eric McDonald <emcd@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/99/2b/97d8e6d847fde37f058965caa7f9a84643924b150d7e5b70282ffc54666e/accretive-2.1.tar.gz",
    "platform": null,
    "description": ".. vim: set fileencoding=utf-8:\n.. -*- coding: utf-8 -*-\n.. +--------------------------------------------------------------------------+\n   |                                                                          |\n   | Licensed under the Apache License, Version 2.0 (the \"License\");          |\n   | you may not use this file except in compliance with the License.         |\n   | You may obtain a copy of the License at                                  |\n   |                                                                          |\n   |     http://www.apache.org/licenses/LICENSE-2.0                           |\n   |                                                                          |\n   | Unless required by applicable law or agreed to in writing, software      |\n   | distributed under the License is distributed on an \"AS IS\" BASIS,        |\n   | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |\n   | See the License for the specific language governing permissions and      |\n   | limitations under the License.                                           |\n   |                                                                          |\n   +--------------------------------------------------------------------------+\n\n*******************************************************************************\n                                  accretive\n*******************************************************************************\n\n.. image:: https://img.shields.io/pypi/v/accretive\n   :alt: Project Version\n   :target: https://pypi.org/project/accretive/\n\n.. image:: https://img.shields.io/pypi/status/accretive\n   :alt: PyPI - Status\n   :target: https://pypi.org/project/accretive/\n\n.. image:: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml/badge.svg?branch=master&event=push\n   :alt: Tests Status\n   :target: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml\n\n.. image:: https://emcd.github.io/python-accretive/coverage.svg\n   :alt: Code Coverage Percentage\n   :target: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml\n\n.. image:: https://img.shields.io/pypi/pyversions/accretive\n   :alt: Python Versions\n   :target: https://pypi.org/project/accretive/\n\n.. image:: https://img.shields.io/pypi/l/accretive\n   :alt: Project License\n   :target: https://github.com/emcd/python-accretive/blob/master/LICENSE.txt\n\n\n\ud83d\udd12 A Python library package which provides **accretive data structures** -\ncollections which can grow but never shrink.\n\n\nKey Features \u2b50\n===============================================================================\n\n* \ud83d\udcd6 **Accretive Dictionary**: Like a regular `dict\n  <https://docs.python.org/3/library/stdtypes.html#dict>`_, but entries cannot\n  be modified or removed once added. Also has variants with defaults and\n  validation.\n* \ud83d\uddc3\ufe0f **Accretive Namespace**: Similar to `SimpleNamespace\n  <https://docs.python.org/3/library/types.html#types.SimpleNamespace>`_, but\n  attributes become immutable after assignment.\n* \ud83e\uddf1 **Additional Types**: Classes (including abstract base classes), modules,\n  and objects with accretive behavior.\n* \ud83c\udfd7\ufe0f **Flexible Initialization**: Support for unprotected attributes during\n  initialization; useful for compatibility with class decorators, such as\n  `dataclasses\n  <https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass>`_.\n\n\nNote on Immutability \ud83d\udce2\n===============================================================================\n\n   Enforcement of immutability is quite difficult in Python. While this library\n   encourages immutability by default, it can be circumvented by anyone who has\n   intermediate knowledge of Python machinery and who is determined to\n   circumvent the immutability. Use the library in the spirit of making\n   programs safer, but understand that it cannot truly prevent unwanted state\n   tampering.\n\n\nInstallation \ud83d\udce6\n===============================================================================\n\n::\n\n    pip install accretive\n\n\nExamples \ud83d\udca1\n===============================================================================\n\n\nAccretive Namespace \ud83d\uddc3\ufe0f\n-------------------------------------------------------------------------------\n\nAn accretive namespace, similar to ``types.SimpleNamespace``, is available.\nThis namespace can be initialized from multiple iterables and from keyword\narguments. (Keyword arguments shown below; see documentation for additional\nforms of initialization.)\n\n>>> from accretive import Namespace\n>>> ns = Namespace( apples = 12, bananas = 6 )\n>>> ns.cherries = 42  # \u2705 Allows new attributes.\n>>> ns.apples = 14    # \u274c Attempted reassignment raises error.\nTraceback (most recent call last):\n...\naccretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'apples'.\n>>> del ns.apples     # \u274c Attempted deletion raises error.\nTraceback (most recent call last):\n...\naccretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'apples'.\n>>> ns\naccretive.namespaces.Namespace( apples = 12, bananas = 6, cherries = 42 )\n\n\nAccretive Dictionary \ud83d\udcd6\n-------------------------------------------------------------------------------\n\nAn accretive dictionary, similar to ``dict``, is available. This dictionary can\nbe initialized from multiple iterables and from keyword arguments. (Keyword\narguments shown below; see documentation for additional forms of\ninitialization.)\n\n>>> from accretive import Dictionary\n>>> dct = Dictionary( apples = 12, bananas = 6 )\n>>> dct[ 'cherries' ] = 42  # \u2705 Allows new entries.\n>>> dct.update( blueberries = 96, strawberries = 24 )\naccretive.dictionaries.Dictionary( {'apples': 12, 'bananas': 6, 'cherries': 42, 'blueberries': 96, 'strawberries': 24} )\n>>> dct[ 'bananas' ] = 11   # \u274c Attempted alteration raises error.\nTraceback (most recent call last):\n...\naccretive.exceptions.EntryImmutabilityError: Cannot alter or remove existing entry for 'bananas'.\n>>> del dct[ 'bananas' ]    # \u274c Attempted removal raises error.\nTraceback (most recent call last):\n...\naccretive.exceptions.EntryImmutabilityError: Cannot alter or remove existing entry for 'bananas'.\n>>> dct\naccretive.dictionaries.Dictionary( {'apples': 12, 'bananas': 6, 'cherries': 42, 'blueberries': 96, 'strawberries': 24} )\n\n\nUse Cases \ud83c\udfaf\n===============================================================================\n\n* \ud83d\udcdd **Configuration Registries**: Registries which can accumulate entries but\n  never remove them, thereby guaranteeing sticky state.\n* \ud83d\udd0c **Plugin Systems**: Register extensions which are then guaranteed to be\n  available from the time of registration to the end of the process.\n* \ud83d\udd12 **Immutable Collections**: Many scenarios requiring grow-only collections\n  with immutability guarantees.\n\n\n`More Flair <https://www.imdb.com/title/tt0151804/characters/nm0431918>`_\n===============================================================================\n\n.. image:: https://img.shields.io/github/last-commit/emcd/python-accretive\n   :alt: GitHub last commit\n   :target: https://github.com/emcd/python-accretive\n\n.. image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg\n   :alt: Hatch\n   :target: https://github.com/pypa/hatch\n\n.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\n   :alt: pre-commit\n   :target: https://github.com/pre-commit/pre-commit\n\n.. image:: https://img.shields.io/badge/security-bandit-yellow.svg\n   :alt: Bandit\n   :target: https://github.com/PyCQA/bandit\n\n.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen\n   :alt: Pylint\n   :target: https://github.com/pylint-dev/pylint\n\n.. image:: https://microsoft.github.io/pyright/img/pyright_badge.svg\n   :alt: Pyright\n   :target: https://microsoft.github.io/pyright/\n\n.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\n   :alt: Ruff\n   :target: https://github.com/astral-sh/ruff\n\n.. image:: https://img.shields.io/pypi/implementation/accretive\n   :alt: PyPI - Implementation\n   :target: https://pypi.org/project/accretive/\n\n.. image:: https://img.shields.io/pypi/wheel/accretive\n   :alt: PyPI - Wheel\n   :target: https://pypi.org/project/accretive/\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Accretive data structures.",
    "version": "2.1",
    "project_urls": {
        "Documentation": "https://emcd.github.io/python-accretive",
        "Download": "https://pypi.org/project/accretive/#files",
        "Homepage": "https://github.com/emcd/python-accretive",
        "Issue Tracker": "https://github.com/emcd/python-accretive/issues",
        "Source Code": "https://github.com/emcd/python-accretive"
    },
    "split_keywords": [
        "accretion",
        " api",
        " dictionary",
        " indelibility",
        " namespace"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d2d1448cd5f97eaa6922338fddd411470fcee7ac8d64f9deafff1d25f2527fcd",
                "md5": "6aba9da95e526556651c4b19458e7de5",
                "sha256": "1a6d491c328ed9cf0a7b501ff20bfe5fcff1141bebd5e3e28bb64031777d4a04"
            },
            "downloads": -1,
            "filename": "accretive-2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6aba9da95e526556651c4b19458e7de5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 28535,
            "upload_time": "2024-11-20T02:29:50",
            "upload_time_iso_8601": "2024-11-20T02:29:50.130905Z",
            "url": "https://files.pythonhosted.org/packages/d2/d1/448cd5f97eaa6922338fddd411470fcee7ac8d64f9deafff1d25f2527fcd/accretive-2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "992b97d8e6d847fde37f058965caa7f9a84643924b150d7e5b70282ffc54666e",
                "md5": "5a436eebcaf81bd4c272dade966acd74",
                "sha256": "80f93cb4ca7d7d56e0778a9596287e6c99014315ac8378c2e865ab88f7263d24"
            },
            "downloads": -1,
            "filename": "accretive-2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5a436eebcaf81bd4c272dade966acd74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 20852,
            "upload_time": "2024-11-20T02:29:52",
            "upload_time_iso_8601": "2024-11-20T02:29:52.277027Z",
            "url": "https://files.pythonhosted.org/packages/99/2b/97d8e6d847fde37f058965caa7f9a84643924b150d7e5b70282ffc54666e/accretive-2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-20 02:29:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "emcd",
    "github_project": "python-accretive",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "accretive"
}
        
Elapsed time: 0.97070s