dictanykey


Namedictanykey JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/eddiethedean/dictanykey
SummaryA dict that can use unhashable keys
upload_time2023-01-20 16:28:39
maintainer
docs_urlNone
authorOdos Matthews
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DictAnyKey: Python Dictionary That Can Use Any Key
[![PyPI Latest Release](https://img.shields.io/pypi/v/dictanykey.svg)](https://pypi.org/project/dictanykey/)

## What is it?

**DictAnyKey** is a Python package that provides a dictionary like object that can use unhashable keys (such as list and dict) as well as hashable keys.

## Main Features
Here are just a few of the things that DictAnyKey does well:
  
  - Use unhashable objects as keys, such as list and dict but with slower retrieval.
  - Stores and retrieves values using hashable keys at same speed as built in dict.
  - Maintains order of insertion just like built in dict.

## Where to get it
The source code is currently hosted on GitHub at:
https://github.com/eddiethedean/dictanykey

```sh
# PyPI
pip install dictanykey
```

## Dependencies
- [python >= 3.6]

## Example
```sh
from dictanykey import DictAnyKey

# Start with empty DictAnyKey
d = DictAnyKey()

# Add value with unhashable key
d[[1, 2]] = 'one two'

# Add value with hashable key
d[1] = 'one'

# Get value with key
d[[1, 2]] -> 'one two'

str(d) -> '{[1, 2]: "one two", 1: "one"}'

# Delete items with del
del d[[1, 2]]

# Start with filled in DictAnyKey, use list of tuples
d = DictAnyDict([([2, 2], 'two two'), (2, 'two')])

str(d) -> '{[2, 2]: "two two", 2: "two"}'

# Has keys, values, and items methods (all results are iterable)
d.keys() -> DictKeys([[2, 2], 2])
d.values() -> DictValues('two two', 'two')
d.items() -> DictItems([([2, 2], 'two two'), (2, 'two')])

# check for key membership
[2, 2] in d -> True
[3, 4] in d -> False

# Has get method with default parameter
d.get(5, default='Missing') -> 'Missing'
d.get([2, 2], default='Missing') -> 'two two'
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/eddiethedean/dictanykey",
    "name": "dictanykey",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Odos Matthews",
    "author_email": "odosmatthews@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/af/4e/b2acad01fb93adaf5ebfc7acb7dc1ab924802f856d5368154e1c616f59c5/dictanykey-0.0.5.tar.gz",
    "platform": null,
    "description": "# DictAnyKey: Python Dictionary That Can Use Any Key\n[![PyPI Latest Release](https://img.shields.io/pypi/v/dictanykey.svg)](https://pypi.org/project/dictanykey/)\n\n## What is it?\n\n**DictAnyKey** is a Python package that provides a dictionary like object that can use unhashable keys (such as list and dict) as well as hashable keys.\n\n## Main Features\nHere are just a few of the things that DictAnyKey does well:\n  \n  - Use unhashable objects as keys, such as list and dict but with slower retrieval.\n  - Stores and retrieves values using hashable keys at same speed as built in dict.\n  - Maintains order of insertion just like built in dict.\n\n## Where to get it\nThe source code is currently hosted on GitHub at:\nhttps://github.com/eddiethedean/dictanykey\n\n```sh\n# PyPI\npip install dictanykey\n```\n\n## Dependencies\n- [python >= 3.6]\n\n## Example\n```sh\nfrom dictanykey import DictAnyKey\n\n# Start with empty DictAnyKey\nd = DictAnyKey()\n\n# Add value with unhashable key\nd[[1, 2]] = 'one two'\n\n# Add value with hashable key\nd[1] = 'one'\n\n# Get value with key\nd[[1, 2]] -> 'one two'\n\nstr(d) -> '{[1, 2]: \"one two\", 1: \"one\"}'\n\n# Delete items with del\ndel d[[1, 2]]\n\n# Start with filled in DictAnyKey, use list of tuples\nd = DictAnyDict([([2, 2], 'two two'), (2, 'two')])\n\nstr(d) -> '{[2, 2]: \"two two\", 2: \"two\"}'\n\n# Has keys, values, and items methods (all results are iterable)\nd.keys() -> DictKeys([[2, 2], 2])\nd.values() -> DictValues('two two', 'two')\nd.items() -> DictItems([([2, 2], 'two two'), (2, 'two')])\n\n# check for key membership\n[2, 2] in d -> True\n[3, 4] in d -> False\n\n# Has get method with default parameter\nd.get(5, default='Missing') -> 'Missing'\nd.get([2, 2], default='Missing') -> 'two two'\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A dict that can use unhashable keys",
    "version": "0.0.5",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4511038215434a0e3a99c2e0d9a7fc01cdcc619010a2fe3ccc8ccf1df08e2bd9",
                "md5": "d14b7a95e46fa3db0b6f385c764021b9",
                "sha256": "2298abfda110defa3a89eb6138bedcd0e9789da7a28cd9dcbed6afdaaa10dafa"
            },
            "downloads": -1,
            "filename": "dictanykey-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d14b7a95e46fa3db0b6f385c764021b9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8770,
            "upload_time": "2023-01-20T16:28:37",
            "upload_time_iso_8601": "2023-01-20T16:28:37.189176Z",
            "url": "https://files.pythonhosted.org/packages/45/11/038215434a0e3a99c2e0d9a7fc01cdcc619010a2fe3ccc8ccf1df08e2bd9/dictanykey-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af4eb2acad01fb93adaf5ebfc7acb7dc1ab924802f856d5368154e1c616f59c5",
                "md5": "09b362913cd4e864f81af3ea3a644613",
                "sha256": "86ae56f8b5e2476bce3a72b7deef3dcf79aa1a6d5e4dab4ee681cde11c992e76"
            },
            "downloads": -1,
            "filename": "dictanykey-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "09b362913cd4e864f81af3ea3a644613",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6880,
            "upload_time": "2023-01-20T16:28:39",
            "upload_time_iso_8601": "2023-01-20T16:28:39.658598Z",
            "url": "https://files.pythonhosted.org/packages/af/4e/b2acad01fb93adaf5ebfc7acb7dc1ab924802f856d5368154e1c616f59c5/dictanykey-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-20 16:28:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "eddiethedean",
    "github_project": "dictanykey",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dictanykey"
}
        
Elapsed time: 0.09337s