{ "info": { "author": "Eevee (Alex Munroe)", "author_email": "eevee.pypi@veekun.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "dictproxyhack\r\n=============\r\n\r\nExposes the immutable ``dictproxy`` type to all (?) versions of Python.\r\n\r\nPEP416_ asked for a ``frozendict`` type, but was rejected. The alternative was\r\nto publicly expose ``dictproxy``, the type used for and immutable object's\r\n``__dict__``, which wraps an existing dict and provides a read-only interface\r\nto it. The type has existed since 2.2, but it's never had a Python-land\r\nconstructor.\r\n\r\nUntil now. But only in 3.3+. Which is not all that helpful to some of us.\r\n\r\nThis module clumsily exposes the same type to previous versions of Python.\r\n\r\n.. _PEP416: http://www.python.org/dev/peps/pep-0416/\r\n\r\nUsage\r\n-----\r\n\r\n::\r\n\r\n from dictproxyhack import dictproxy\r\n\r\n myproxy = dictproxy(dict(foo=\"bar\"))\r\n print(myproxy['foo'])\r\n myproxy['baz'] = \"quux\" # TypeError\r\n\r\nSince the proxy holds a reference to the underlying ``dict`` (but doesn't provide\r\nany way to get it back), you can trivially implement ``frozendict``::\r\n\r\n def frozendict(*args, **kwargs):\r\n return dictproxy(dict(*args, **kwargs))\r\n\r\nMight as well just inline that where you need it, really.\r\n\r\nDependencies\r\n------------\r\n\r\nPython. Should work anywhere. Maybe.\r\n\r\nOn **Python 3.3+**, you get the real ``mappingproxy`` type, which lives in the\r\n``types`` module as ``MappingProxyType``.\r\n\r\nOn **CPython 2.5+**, you get a fake class that forcibly instantiates\r\n``dictproxy`` objects via ``ctypes`` shenanigans.\r\n\r\nOn **nearly anything else**, you get a regular class that wraps a dict and\r\ndoesn't implement any mutating parts of the mapping interface. Not a fabulous\r\nsolution, but good enough, and only applies until your favorite port catches up\r\nwith 3.3's standard library.\r\n\r\nOn **non-C Python ports that predate 2.6**, you get pretty much a ``dict``,\r\nbecause the ``Mapping`` ABC doesn't even exist. Sorry.\r\n\r\nThe shim classes also fool ``isinstance`` and ``issubclass``, so your dirty\r\ntypechecking should work equally poorly anywhere.\r\n\r\nI've only actually tried this library on CPython 2.6, 2.7, 3.2, 3.3, and PyPy\r\n2.1, but I'm interested in hearing whether it works elsewhere.\r\n\r\nGotchas\r\n-------\r\n\r\nDon't subclass ``dictproxy``. Python 3.3+ won't let you, and the shims for other\r\nversions are of extremely dubious use.\r\n\r\n``dictproxy`` has been renamed to ``mappingproxy`` in 3.3+, so don't rely on\r\n``repr`` to match across versions or anything. (It seemed apropos to use the\r\nolder name for this module.)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/eevee/dictproxyhack", "keywords": "", "license": "UNKNOWN", "maintainer": "", "maintainer_email": "", "name": "dictproxyhack", "package_url": "https://pypi.org/project/dictproxyhack/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dictproxyhack/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/eevee/dictproxyhack" }, "release_url": "https://pypi.org/project/dictproxyhack/1.1/", "requires_dist": null, "requires_python": null, "summary": "PEP 417's dictproxy (immutable dicts) for everyone", "version": "1.1" }, "last_serial": 833141, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "4554469ed3b14ffb63accfc9816c6256", "sha256": "2fe60c690f7211af43de74a3b2316889dfba5898f8f0a312fbee690b203dd3e8" }, "downloads": -1, "filename": "dictproxyhack-1.0.tar.gz", "has_sig": false, "md5_digest": "4554469ed3b14ffb63accfc9816c6256", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3216, "upload_time": "2013-08-06T02:16:43", "url": "https://files.pythonhosted.org/packages/aa/9b/ee0dadbe0fdb85c6ef0574ec8c65a43b9ca609004af8dbb7124130ffdc3d/dictproxyhack-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "5083fcc4ef164403d609a4ff9f9f659c", "sha256": "964eef82fba883d53783b08cbce90415380a5c26e5c2dba47548d1c3d0a591f8" }, "downloads": -1, "filename": "dictproxyhack-1.1.tar.gz", "has_sig": false, "md5_digest": "5083fcc4ef164403d609a4ff9f9f659c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3278, "upload_time": "2013-08-06T03:33:35", "url": "https://files.pythonhosted.org/packages/96/f7/fee4c0445d3ccf8447a22f7d557b65134d4424852748e62db0b931ed4601/dictproxyhack-1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5083fcc4ef164403d609a4ff9f9f659c", "sha256": "964eef82fba883d53783b08cbce90415380a5c26e5c2dba47548d1c3d0a591f8" }, "downloads": -1, "filename": "dictproxyhack-1.1.tar.gz", "has_sig": false, "md5_digest": "5083fcc4ef164403d609a4ff9f9f659c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3278, "upload_time": "2013-08-06T03:33:35", "url": "https://files.pythonhosted.org/packages/96/f7/fee4c0445d3ccf8447a22f7d557b65134d4424852748e62db0b931ed4601/dictproxyhack-1.1.tar.gz" } ] }