{"id":17968847,"url":"https://github.com/matthiasdiener/constantdict","last_synced_at":"2025-03-25T10:32:40.739Z","repository":{"id":218311985,"uuid":"746108943","full_name":"matthiasdiener/constantdict","owner":"matthiasdiener","description":"An immutable dict class for Python.","archived":false,"fork":false,"pushed_at":"2025-03-03T22:39:40.000Z","size":362,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T04:06:49.066Z","etag":null,"topics":["dict","frozen","immutable","python"],"latest_commit_sha":null,"homepage":"https://matthiasdiener.github.io/constantdict/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthiasdiener.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-21T04:30:43.000Z","updated_at":"2025-03-03T22:39:44.000Z","dependencies_parsed_at":"2024-01-21T05:25:14.216Z","dependency_job_id":"e66e4537-29a0-448f-86c9-ea189c01d27c","html_url":"https://github.com/matthiasdiener/constantdict","commit_stats":null,"previous_names":["matthiasdiener/constantdict"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthiasdiener%2Fconstantdict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthiasdiener%2Fconstantdict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthiasdiener%2Fconstantdict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthiasdiener%2Fconstantdict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthiasdiener","download_url":"https://codeload.github.com/matthiasdiener/constantdict/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245444475,"owners_count":20616388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dict","frozen","immutable","python"],"created_at":"2024-10-29T14:41:43.989Z","updated_at":"2025-03-25T10:32:40.731Z","avatar_url":"https://github.com/matthiasdiener.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI version](https://badge.fury.io/py/constantdict.svg)](https://badge.fury.io/py/constantdict)\n[![Doc Status](https://img.shields.io/github/actions/workflow/status/matthiasdiener/constantdict/doc.yaml?label=docs)](https://matthiasdiener.github.io/constantdict)\n[![License](https://img.shields.io/pypi/l/constantdict)](https://github.com/matthiasdiener/constantdict/blob/main/LICENSE)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/constantdict)](https://badge.fury.io/py/constantdict)\n\n# constantdict\n\nAn immutable dictionary class for Python, implemented as a thin layer around Python's builtin `dict` class. It is often [faster than other immutable dictionary implementations](https://matthiasdiener.github.io/constantdict/comparison.html).\n\n## Usage\n\nInstall this package with:\n```\n$ pip install constantdict\n```\n\nUsage example:\n```python\nfrom constantdict import constantdict\n\ncd = constantdict({1: 2})\n\n# constantdicts compare equal to dicts with the same items\nassert cd == {1: 2}\n\n# constantdicts are hashable, and their hashes are cached\nprint(hash(cd), cd)\n\n# Attempting to modify a constantdict in-place raises an AttributeError\ntry:\n    # Similar for pop(), popitem(), clear(), and del\n    cd[4] = 12\nexcept AttributeError:\n    pass\n\n# Some methods return a mutated copy of a constantdict\ncd_new = cd.setdefault(10, 5)\nassert cd_new == {1: 2, 10: 5}\n# Similar for set(), update(), delete(), discard()\n\n# Performing multiple mutations can be faster via mutate()/finish()\ncd_mut = cd.mutate()  # cd_mut is a mutable copy of cd\ncd_mut[42] = 0\ndel cd_mut[1]\ncd_new2 = cd_mut.finish()  # cd_new2 is an immutable version of cd_mut\nassert cd_new2 == {42: 0}\n```\n\nPlease also see the [documentation](https://matthiasdiener.github.io/constantdict),\nas well as the examples in the `examples/` directory.\n\n\n## References\n\n### Other packages\n\n- [immutabledict](https://github.com/corenting/immutabledict)\n- [immutables](https://github.com/MagicStack/immutables)\n- [pyrsistent](https://github.com/tobgu/pyrsistent)\n- [frozendict (old)](https://github.com/slezica/python-frozendict)\n- [frozendict (new)](https://github.com/Marco-Sulla/python-frozendict)\n\n\n### PEPs\n\n- [PEP 416](https://www.python.org/dev/peps/pep-0416/)\n- [PEP 603](https://www.python.org/dev/peps/pep-0603/)\n\n### Discussions\n\n- [PEP 603: Adding a frozenmap type to collections](https://discuss.python.org/t/pep-603-adding-a-frozenmap-type-to-collections/2318)\n\n## License\n\nMIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthiasdiener%2Fconstantdict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthiasdiener%2Fconstantdict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthiasdiener%2Fconstantdict/lists"}