{ "info": { "author": "F\u00e1bio Mac\u00eado Mendes", "author_email": "fabiomacedomendes@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Programming Language :: Python", "Topic :: Software Development :: Libraries" ], "description": "Lazyutils provides a few simple utilities for lazy evaluation of code.\n\n\nLazy attribute\n==============\n\nThe lazy decorator defines an attribute with deferred initialization::\n\n.. code::python\n import math\n from lazyutils import lazy\n\n class Vec:\n def __init__(self, x, y):\n self.x, self.y = x, y\n\n @lazy\n def magnitude(self):\n print('computing...')\n return math.sqrt(self.x**2 + self.y**2)\n\nNow the ``magnitude`` attribute is initialized and cached upon first use:\n\n>>> v = Vec(3, 4)\n>>> v.magnitude\ncomputing...\n5.0\n\nThe attribute is writable and apart from the deferred initialization, it behaves\njust like any regular Python attribute.\n\n>>> v.magnitude = 42\n>>> v.magnitude\n42\n\nLazy attributes can be useful either to simplify the implementation of the\n__init__ method of objects that initialize a great number or variables or as an\noptimization that delays potentially expensive computations that may not be\nnecessary in the object's lifecycle.\n\n\nDelegation\n==========\n\nThe delegate_to() function delegates some attribute to an attribute during the\nclass definition::\n\n.. code::python\n from lazyutils import delegate_to\n \n class Arrow:\n magnitude = delegate_to('vector')\n\n def __init__(self, vector, start=Vec(0, 0)):\n self.vector = vector\n self.start = start\n\nNow, the ``.magnitude`` attribute of ``Arrow`` instances is delegated to\n``.vector.magnitude``. Delegate fields are useful in class composition when one\nwants to expose a few selected attributes from the inner objects. delegate_to()\nhandles attributes and methods with no distinction.\n\n\n>>> a = Arrow(Vec(6, 8))\n>>> a.magnitude\ncomputing...\n10.0\n\n\nAliasing\n========\n\nAliasing is a very simple form of delegation. We can create simple aliases for\nattributes using the alias() and readonly() functions::\n\n class MyArrow(Arrow):\n abs_value = readonly('magnitude')\n origin = alias('start')\n\nThis exposes two additional properties: \"abs_value\" and \"origin\". The first is\njust a read-only view on the \"magnitude\" property. The second exposes read and\nwrite access to the \"start\" attribute.", "description_content_type": null, "docs_url": "https://pythonhosted.org/lazyutils/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/fabiommendes/lazyutils/", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "lazyutils", "package_url": "https://pypi.org/project/lazyutils/", "platform": "any", "project_url": "https://pypi.org/project/lazyutils/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/fabiommendes/lazyutils/" }, "release_url": "https://pypi.org/project/lazyutils/0.3.3/", "requires_dist": null, "requires_python": null, "summary": "Lazy accessor and other tools for deferred evaluation.", "version": "0.3.3" }, "last_serial": 2354826, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "fc3a0a5dab7c8a0aa83950143ee9801b", "sha256": "62af4823917d01b8e9eb32377853fe7a701163f5eb7db3c339151cf624324b8a" }, "downloads": -1, "filename": "lazyutils-0.1.0.tar.gz", "has_sig": false, "md5_digest": "fc3a0a5dab7c8a0aa83950143ee9801b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4032, "upload_time": "2016-07-08T22:22:05", "url": "https://files.pythonhosted.org/packages/5c/d2/b012ebe66e7711ed8dd71ca36f6f82ec490661cbc893a420ab68c2d6d682/lazyutils-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "8f3151b4dd0b52e67e84bbeef4bd9b0c", "sha256": "dfea75a12b437ea9e427151f05a84848d8814147064bf6a7eb36e6eb11eeb6bf" }, "downloads": -1, "filename": "lazyutils-0.1.1.tar.gz", "has_sig": false, "md5_digest": "8f3151b4dd0b52e67e84bbeef4bd9b0c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4374, "upload_time": "2016-07-08T22:26:42", "url": "https://files.pythonhosted.org/packages/8e/d7/fb8236c0a6b54e5dd5044dea6c6cf9bef539b58c420216250080fb2d2dbe/lazyutils-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "8ed92054c5d050f249abfa711f284738", "sha256": "283ad46ae93d74a1c13d54a6d4a939dc3bc0cf3ddfd75b87a655c930015b0849" }, "downloads": -1, "filename": "lazyutils-0.2.0.tar.gz", "has_sig": false, "md5_digest": "8ed92054c5d050f249abfa711f284738", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5254, "upload_time": "2016-07-09T15:40:00", "url": "https://files.pythonhosted.org/packages/8b/be/a53853266d980349129169a781f3519bf6641570e0a304949a1794521b04/lazyutils-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "c4c2ca5b61289ceaba6bc34ab4cd77b7", "sha256": "b39b9655ac8b216811774a27d1587720ab6dc4cc0a78f1c4f03e9208956c8847" }, "downloads": -1, "filename": "lazyutils-0.2.1.tar.gz", "has_sig": false, "md5_digest": "c4c2ca5b61289ceaba6bc34ab4cd77b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5258, "upload_time": "2016-07-09T15:41:41", "url": "https://files.pythonhosted.org/packages/34/f3/9c70d7709f1827d82b0ab367d6fdaf8f449891aa57e6506cbc2af3cf8212/lazyutils-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "8faba6799daaa610b2863d61848edccf", "sha256": "573d14394993386916f15ba00e2347f44732e0d627fb8dbffa4f4fb44004cc33" }, "downloads": -1, "filename": "lazyutils-0.2.2.tar.gz", "has_sig": false, "md5_digest": "8faba6799daaa610b2863d61848edccf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5246, "upload_time": "2016-07-09T15:44:02", "url": "https://files.pythonhosted.org/packages/2c/a7/cea4bad773f4ef49f1e986a97798c1adc19b6103cc67568ca0699b346287/lazyutils-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "01211aa06b538b1dee11856562fa7481", "sha256": "b3c9e402251693228bcb562a08c1024d67efeab09534442504f4807797df150e" }, "downloads": -1, "filename": "lazyutils-0.2.3.tar.gz", "has_sig": false, "md5_digest": "01211aa06b538b1dee11856562fa7481", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5409, "upload_time": "2016-08-12T03:22:58", "url": "https://files.pythonhosted.org/packages/27/00/07a299f3ea89d81e64d340fb6ef31872747542d95c2b1d5cff9821816f9d/lazyutils-0.2.3.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "f52480b875d78d292e3badf21c1662be", "sha256": "9b660750c9c38243b2497da8b8f43d2180c46562067eea3fe709b67be9a5d88a" }, "downloads": -1, "filename": "lazyutils-0.3.0.tar.gz", "has_sig": false, "md5_digest": "f52480b875d78d292e3badf21c1662be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5791, "upload_time": "2016-08-12T03:35:04", "url": "https://files.pythonhosted.org/packages/5d/a0/a5d44f5ac3b774893ecd80f60e328035e916b897a0ec07f0635b864955d3/lazyutils-0.3.0.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "5785e15273dc2a8299f6a9803655560c", "sha256": "0d5c21a3c5bc6b51f7adaf6a84ff12c6d399754dec5ff40a1ad91c11f8a8a387" }, "downloads": -1, "filename": "lazyutils-0.3.2.tar.gz", "has_sig": false, "md5_digest": "5785e15273dc2a8299f6a9803655560c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6086, "upload_time": "2016-08-12T23:52:43", "url": "https://files.pythonhosted.org/packages/38/ce/38849e55ed3af635123954e7a71d59cec17e6933e8e26637fcae999715f5/lazyutils-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "1af207376128ffa64133e5af4f644647", "sha256": "18c246854e257d6843b12e3b43cd00fadfb547ba51cdb80f4d14d9ccaa5aa444" }, "downloads": -1, "filename": "lazyutils-0.3.3.tar.gz", "has_sig": false, "md5_digest": "1af207376128ffa64133e5af4f644647", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6884, "upload_time": "2016-09-21T11:53:51", "url": "https://files.pythonhosted.org/packages/de/23/c7ebd89f7b75f1f95b4dd5e9e77d4d4761d694e9b0ad61b17fda8e57007c/lazyutils-0.3.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1af207376128ffa64133e5af4f644647", "sha256": "18c246854e257d6843b12e3b43cd00fadfb547ba51cdb80f4d14d9ccaa5aa444" }, "downloads": -1, "filename": "lazyutils-0.3.3.tar.gz", "has_sig": false, "md5_digest": "1af207376128ffa64133e5af4f644647", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6884, "upload_time": "2016-09-21T11:53:51", "url": "https://files.pythonhosted.org/packages/de/23/c7ebd89f7b75f1f95b4dd5e9e77d4d4761d694e9b0ad61b17fda8e57007c/lazyutils-0.3.3.tar.gz" } ] }