{ "info": { "author": "Akshat Mahajan", "author_email": "akshatm.bkk@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: Other Audience", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development", "Topic :: Utilities" ], "description": "About\n=====\n\nThis library enables dictionaries and lists to be used as keys inside a\ndictionary. In other words, it makes them hashable.\n\nWhile mutable objects (lists, dictionaries) should not be made hashable\nin general, the programmer is trusted not to abuse this power (you *do*\ntest your code before shipping into production, don't you?). An\nextension option to explicitly make the resulting hashable object\nimmutable is provided below for convenience.\n\nThere are certain use cases - e.g. when trying to pass seemingly\nidentical keys to `NetworkX `__ as different\nnodes, or when you want to query an object's properties in place while\nmaking a mapping instead of calling a complicated identification\nfunction - where these may be useful and reduce boilerplate code.\n\nUsage\n=====\n\n::\n\n >>> from hashable_collections.hashable_collections import hashable_dict\n >>> hashed_dict = hashable_dict({'name':'foo'})\n >>> from hashable_collections.hashable_collections import hashable_list\n >>> hashed_list = hashable_list(['bar',1])\n >>> output = {hashed_dict:0,hashed_list:1}\n >>> output\n {{'name':'foo'}: 0, ['bar', 1]: 1}\n\nThese hashable objects still retain mutability - in other words, it is\nstill possible to assign ``hashed_dict['squiggle'] = 'squiggle'`` and\nhave it execute without an issue. The hash will change correspondingly,\neffectively making it a different object from before.\n\nAlternatively, one can subclass the objects defined here and override\nthe ``__setitem__`` method to make sure the resulting hashable\ndictionary/list is immutable:\n\n::\n\n class immutable_hashable_dict(hashable_dict):\n\n def __setitem__(self,key,value):\n raise ValueError('Immutable hashable dicts do not let you change values inside your dictionary.')\n\n class immutable_hashable_list(hashable_list):\n\n def __setitem__(self,key,value):\n raise ValueError('Immutable hashable lists do not let you change valus inside your list.')\n\nCaveats\n=======\n\nThe following is a list of known issues that may crop up with this\ntechnology.\n\n- Creating a copy: If ``s`` is a ``hashable_dict``, and one does\n ``m = s`` and then changes ``m[0]``, the corresponding value of\n ``s[0]`` is changed as well. **Never** assign an existing\n hashable\\_dict or hashable\\_list to another object unless you are\n sure the second object is not going to change.\n\nInstallation\n============\n\n``pip install hashable_collections``", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://akshatm.github.io/hashable_collections/", "keywords": "hash,dictionary,lists", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "hashable_collections", "package_url": "https://pypi.org/project/hashable_collections/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/hashable_collections/", "project_urls": { "Homepage": "http://akshatm.github.io/hashable_collections/" }, "release_url": "https://pypi.org/project/hashable_collections/1.1/", "requires_dist": null, "requires_python": null, "summary": "Hashable dictionaries and lists", "version": "1.1" }, "last_serial": 1688657, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "081d36078ada5aac0bcbe9bd98edf9e9", "sha256": "b268cd04b3b34f1fc5dfa962d97c9bc269dd11234e6c28ddbb1061f97d03594c" }, "downloads": -1, "filename": "hashable_collections-1.0-cp34-none-win32.whl", "has_sig": false, "md5_digest": "081d36078ada5aac0bcbe9bd98edf9e9", "packagetype": "bdist_wheel", "python_version": "cp34", "requires_python": null, "size": 1896, "upload_time": "2015-08-20T16:04:55", "url": "https://files.pythonhosted.org/packages/c5/c4/285ae13a552b6b3343581b74ef9d337ef9f412558866937975a74b9540d8/hashable_collections-1.0-cp34-none-win32.whl" }, { "comment_text": "", "digests": { "md5": "f0850495b9dae24ce3b78e63eb08a813", "sha256": "dcbf5f09ae6c1b46559b7a6f366cea91e52b4a59d1b724e6f9786d4945745565" }, "downloads": -1, "filename": "hashable_collections-1.0.zip", "has_sig": false, "md5_digest": "f0850495b9dae24ce3b78e63eb08a813", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6666, "upload_time": "2015-08-20T16:05:01", "url": "https://files.pythonhosted.org/packages/1f/33/00e8cbc7cd22dcd83323182dbc934746b223450abd7d246df68d9423cea1/hashable_collections-1.0.zip" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "708cff1d058f246bc864d80446cbd80a", "sha256": "382075754eeeeee1ee8822bb594b37a09094fa19e5c3f72a7f98c6b2b4a711b9" }, "downloads": -1, "filename": "hashable_collections-1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "708cff1d058f246bc864d80446cbd80a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5590, "upload_time": "2015-08-22T12:02:16", "url": "https://files.pythonhosted.org/packages/ac/63/1de6ab75df2ab9a3bb50d3f0c36e24f2ead440263c9adc4a1ca067b8b293/hashable_collections-1.1-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "708cff1d058f246bc864d80446cbd80a", "sha256": "382075754eeeeee1ee8822bb594b37a09094fa19e5c3f72a7f98c6b2b4a711b9" }, "downloads": -1, "filename": "hashable_collections-1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "708cff1d058f246bc864d80446cbd80a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5590, "upload_time": "2015-08-22T12:02:16", "url": "https://files.pythonhosted.org/packages/ac/63/1de6ab75df2ab9a3bb50d3f0c36e24f2ead440263c9adc4a1ca067b8b293/hashable_collections-1.1-py2.py3-none-any.whl" } ] }