{ "info": { "author": "Caleb Hattingh", "author_email": "caleb.hattingh@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": ".. image:: https://img.shields.io/badge/stdlib--only-yes-green.svg\n :target: https://img.shields.io/badge/stdlib--only-yes-green.svg\n\n.. image:: https://travis-ci.org/cjrh/autoslot.svg?branch=master\n :target: https://travis-ci.org/cjrh/autoslot\n\n.. image:: https://coveralls.io/repos/github/cjrh/autoslot/badge.svg?branch=master\n :target: https://coveralls.io/github/cjrh/autoslot?branch=master\n\n.. image:: https://img.shields.io/pypi/pyversions/autoslot.svg\n :target: https://pypi.python.org/pypi/autoslot\n\n.. image:: https://img.shields.io/github/tag/cjrh/autoslot.svg\n :target: https://img.shields.io/github/tag/cjrh/autoslot.svg\n\n.. image:: https://img.shields.io/badge/install-pip%20install%20autoslot-ff69b4.svg\n :target: https://img.shields.io/badge/install-pip%20install%20autoslot-ff69b4.svg\n\n.. image:: https://img.shields.io/pypi/v/autoslot.svg\n :target: https://img.shields.io/pypi/v/autoslot.svg\n\n.. image:: https://img.shields.io/badge/calver-YYYY.MM.MINOR-22bfda.svg\n :target: http://calver.org/\n\nautoslot\n========\n\nAutomatic \"__slots__\".\n\nDemo\n----\n\n.. code-block:: python\n\n from autoslot import Slots\n\n class Compact(Slots):\n def __init__(self, a, b):\n self.x = a\n self.y = b\n\nThis produces *exactly* the same class as if you had done:\n\n.. code-block:: python\n\n class Compact:\n __slots__ = {'x', 'y'}\n def __init__(self, a, b):\n self.x = a\n self.y = b\n\nSimply: the code inside ``__init__()`` is scanned to find all assignments\nto attributes on ``self``, and these are added as ``__slots__``.\n\nThe benefit of using ``autoslot.Slots`` over a manual slots declaration is\nthat you can modify the\ncode inside the ``__init__()`` method to add more attributes, and those\nchanges will *automatically* be reflected in the ``__slots__`` definition.\n\nYou can also have the best of both worlds: slots for fields you expect,\n**as well as** a ``__dict__`` for those you don't:\n\n.. code-block:: python\n\n from autoslot import SlotsPlusDict\n\n class SemiCompact(SlotsPlusDict):\n def __init__(self, a, b):\n self.x = a\n self.y = b\n\n inst = SemiCompact(1, 2)\n inst.z = 123 # <-- This won't fail!\n\nAttributes ``x`` and ``y`` will be stored in slots, while all other\ndynamically-assigned attributes will go into the usual ``__dict__`` instance\ninside the class. If most of your class's attributes appear in the ``__init__()``\nmethod (these will become slots), then the space bloat caused by dictionary\nhash-table expansion will be contained to only the dynamically-assigned\nattributes.\n\nHow does it work?\n-----------------\n\nSee for yourself! The code is tiny.\n\nIn words: the metaclass finds the ``__init__()`` method, if present, and\naccesses its bytecode. It looks for all assignments to attributes of\n``self``, and considers those to be desired ``__slots__`` entries. Then the\nmetaclass injects ``__slots__`` into the namespace of the class definition\nand thereafter allows class creation to proceed as normal.\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pythonomicon.com", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "autoslot", "package_url": "https://pypi.org/project/autoslot/", "platform": "", "project_url": "https://pypi.org/project/autoslot/", "project_urls": { "Homepage": "http://pythonomicon.com" }, "release_url": "https://pypi.org/project/autoslot/2018.8.1/", "requires_dist": null, "requires_python": ">=3.5", "summary": "Classes and metaclasses for easier ``__slots__`` handling. ", "version": "2018.8.1" }, "last_serial": 4164994, "releases": { "2017.10.3": [ { "comment_text": "", "digests": { "md5": "7d4761516faa32bf4ee00ed6c4ad0133", "sha256": "e18d90dd13a93d4c946ad33ced1e339f04d9089891bb637621f66d46b6d575e7" }, "downloads": -1, "filename": "autoslot-2017.10.3-py3-none-any.whl", "has_sig": false, "md5_digest": "7d4761516faa32bf4ee00ed6c4ad0133", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 16239, "upload_time": "2017-10-04T03:13:11", "url": "https://files.pythonhosted.org/packages/84/08/0684ad16ef5ba2fd92f269b44651ed69a0ec43c1630c09034f9450381f73/autoslot-2017.10.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ddddfb002277f55f246185e269fdc4ec", "sha256": "208253af5168297c85edb60a8c32dcc70cd6e66d36a2bd92d5f4be98c401020a" }, "downloads": -1, "filename": "autoslot-2017.10.3.tar.gz", "has_sig": false, "md5_digest": "ddddfb002277f55f246185e269fdc4ec", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 8992, "upload_time": "2017-10-04T03:13:13", "url": "https://files.pythonhosted.org/packages/6c/f9/a5aaeaa45fab80bcc02e7d76dcfdaf77e95b8824881d4f2dd1734e4cd966/autoslot-2017.10.3.tar.gz" } ], "2017.10.6": [ { "comment_text": "", "digests": { "md5": "8e91d6a1223ea0e72a1af81f210f5a94", "sha256": "35abd005dc8fe94c78f3229f8d75454eb7a22c091a00ec6ec5080e77d048b361" }, "downloads": -1, "filename": "autoslot-2017.10.6-py3-none-any.whl", "has_sig": false, "md5_digest": "8e91d6a1223ea0e72a1af81f210f5a94", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 16502, "upload_time": "2017-10-04T03:27:05", "url": "https://files.pythonhosted.org/packages/e0/e2/0c2570c30d5b41681df92bb8939385ed83eaabf58d3ddfd1b9adc0348adb/autoslot-2017.10.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6ed113df81d710ebd47963fb37b99c63", "sha256": "0b50c6d89adf600b32ebe1fbab6c9c53684f32eb2d7eac22f3edb3fe2ee727b8" }, "downloads": -1, "filename": "autoslot-2017.10.6.tar.gz", "has_sig": false, "md5_digest": "6ed113df81d710ebd47963fb37b99c63", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 9214, "upload_time": "2017-10-04T03:27:09", "url": "https://files.pythonhosted.org/packages/d3/b1/51564af9154f293eda9efeff40f98e7c158619d75935d28b3f71a6ab92e6/autoslot-2017.10.6.tar.gz" } ], "2018.8.1": [ { "comment_text": "", "digests": { "md5": "80443454ca6dfc06d80de35e89094528", "sha256": "0a98d801ba7f077498809f7b55f26381428860c1517ad4fbcfb0d0faa2292783" }, "downloads": -1, "filename": "autoslot-2018.8.1-py3-none-any.whl", "has_sig": false, "md5_digest": "80443454ca6dfc06d80de35e89094528", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 16547, "upload_time": "2018-08-13T12:31:14", "url": "https://files.pythonhosted.org/packages/aa/6d/0cceebfdad9a0b5d3eb7f573f7c5da2301ce8297c2d83add1bbef0035e72/autoslot-2018.8.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5f935d06d320aa69e9dae3f0d421ff74", "sha256": "8312ff362e9bde27876a74c9776203a282855feeb6ba343494dff140ecb1e51d" }, "downloads": -1, "filename": "autoslot-2018.8.1.tar.gz", "has_sig": false, "md5_digest": "5f935d06d320aa69e9dae3f0d421ff74", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 9462, "upload_time": "2018-08-13T12:31:23", "url": "https://files.pythonhosted.org/packages/db/4f/07b15aa97bb851325e15910bd514a32c66a149dced6d5368841777cee11d/autoslot-2018.8.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "80443454ca6dfc06d80de35e89094528", "sha256": "0a98d801ba7f077498809f7b55f26381428860c1517ad4fbcfb0d0faa2292783" }, "downloads": -1, "filename": "autoslot-2018.8.1-py3-none-any.whl", "has_sig": false, "md5_digest": "80443454ca6dfc06d80de35e89094528", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 16547, "upload_time": "2018-08-13T12:31:14", "url": "https://files.pythonhosted.org/packages/aa/6d/0cceebfdad9a0b5d3eb7f573f7c5da2301ce8297c2d83add1bbef0035e72/autoslot-2018.8.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5f935d06d320aa69e9dae3f0d421ff74", "sha256": "8312ff362e9bde27876a74c9776203a282855feeb6ba343494dff140ecb1e51d" }, "downloads": -1, "filename": "autoslot-2018.8.1.tar.gz", "has_sig": false, "md5_digest": "5f935d06d320aa69e9dae3f0d421ff74", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 9462, "upload_time": "2018-08-13T12:31:23", "url": "https://files.pythonhosted.org/packages/db/4f/07b15aa97bb851325e15910bd514a32c66a149dced6d5368841777cee11d/autoslot-2018.8.1.tar.gz" } ] }