{ "info": { "author": "Shay Palachy", "author_email": "shaypal5@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "decore\n#########\n|PyPI-Status| |PyPI-Versions| |Build-Status| |Codecov| |LICENCE|\n\nA small pure-python package for utility decorators.\n\n.. code-block:: python\n\n from decore import lazy_property\n\n @lazy_property\n def paramless_big_calc():\n sub_res = [big_func(const) for const in array_of_constants]\n return sum(sub_res)\n\n.. contents::\n\n.. section-numbering::\n\n\nInstallation\n============\n\nInstall ``decore`` with:\n\n.. code-block:: bash\n\n pip install decore\n\n\nDecorators\n==========\n\nlazy_property\n-------------\n\nThe ``lazy_property`` decorator is meant to decorate functions that compute some constant value or property that you only want to compute once. The first call to the decorated function will run it and save the value (in memory) before returning it; subsequent calls will get this value without trigerring the calculation.\n\nYou can think about it like a ``functools.lru_cache(maxsize=1)`` for functions with no parameters.\n\n.. code-block:: python\n\n from decore import lazy_property\n\n @lazy_property\n def paramless_big_calc():\n \"\"\"I take a lot of time!\"\"\"\n sub_res = [big_func(const) for const in array_of_constants]\n return sum(sub_res)\n\n\nthreadsafe_generator\n--------------------\n\nThe ``threadsafe_generator`` decorator makes generators threadsafe. This means multiple threads can be given references to the decorated generator and it is guarenteed that each item in the stream will be yielded (i.e. returned) to only a single thread.\n\n.. code-block:: python\n\n from decore import threadsafe_generator\n\n @threadsafe_generator\n def user_documents(day):\n \"\"\"I yield some MongoDB documents!\"\"\"\n client = get_mongodb_client(some_params)\n dt_obj = translate_day_to_dt(day)\n user_document_cursor = client.some_mongodb_query(dt_obj, SOME_CONST)\n while True:\n yield user_document_cursor.__next__()\n\n\nContributing\n============\n\nPackage author and current maintainer is Shay Palachy (shay.palachy@gmail.com); You are more than welcome to approach him for help. Contributions are very welcomed.\n\nInstalling for development\n--------------------------\n\nClone:\n\n.. code-block:: bash\n\n git clone git@github.com:shaypal5/decore.git\n\n\nInstall in development mode with test dependencies:\n\n.. code-block:: bash\n\n cd pdpipe\n pip install -e \".[test]\"\n\n\nRunning the tests\n-----------------\n\nTo run the tests, use:\n\n.. code-block:: bash\n\n python -m pytest --cov=decore\n\n\nAdding documentation\n--------------------\n\nThis project is documented using the `numpy docstring conventions`_, which were chosen as they are perhaps the most widely-spread conventions that are both supported by common tools such as Sphinx and result in human-readable docstrings (in my personal opinion, of course). When documenting code you add to this project, please follow `these conventions`_.\n\n.. _`numpy docstring conventions`: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt\n.. _`these conventions`: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt\n\n\nCredits\n=======\nCreated by Shay Palachy (shay.palachy@gmail.com).\n\n.. |PyPI-Status| image:: https://img.shields.io/pypi/v/decore.svg\n :target: https://pypi.python.org/pypi/decore\n\n.. |PyPI-Versions| image:: https://img.shields.io/pypi/pyversions/decore.svg\n :target: https://pypi.python.org/pypi/decore\n\n.. |Build-Status| image:: https://travis-ci.org/shaypal5/decore.svg?branch=master\n :target: https://travis-ci.org/shaypal5/decore\n\n.. |LICENCE| image:: https://img.shields.io/pypi/l/decore.svg\n :target: https://pypi.python.org/pypi/decore\n\n.. |Codecov| image:: https://codecov.io/github/shaypal5/decore/coverage.svg?branch=master\n :target: https://codecov.io/github/shaypal5/decore?branch=master\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/shaypal5/decore", "keywords": "python decorator decorators", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "decore", "package_url": "https://pypi.org/project/decore/", "platform": "any", "project_url": "https://pypi.org/project/decore/", "project_urls": { "Homepage": "https://github.com/shaypal5/decore" }, "release_url": "https://pypi.org/project/decore/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "A small pure-python package for utility decorators.", "version": "0.0.1" }, "last_serial": 3218149, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "dce2b743c6601ee8e7a50a7d62540403", "sha256": "2aff5856b50e1650dd7b2294722994a359ea05966c2303dca9b017d97219f9aa" }, "downloads": -1, "filename": "decore-0.0.1.tar.gz", "has_sig": false, "md5_digest": "dce2b743c6601ee8e7a50a7d62540403", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19685, "upload_time": "2017-10-02T08:59:18", "url": "https://files.pythonhosted.org/packages/b4/69/9e3da3a87058d43e5b9f0f668f69da591b8b0c2763b3afbfea084582ea57/decore-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dce2b743c6601ee8e7a50a7d62540403", "sha256": "2aff5856b50e1650dd7b2294722994a359ea05966c2303dca9b017d97219f9aa" }, "downloads": -1, "filename": "decore-0.0.1.tar.gz", "has_sig": false, "md5_digest": "dce2b743c6601ee8e7a50a7d62540403", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19685, "upload_time": "2017-10-02T08:59:18", "url": "https://files.pythonhosted.org/packages/b4/69/9e3da3a87058d43e5b9f0f668f69da591b8b0c2763b3afbfea084582ea57/decore-0.0.1.tar.gz" } ] }