methodtools


Namemethodtools JSON
Version 0.4.7 PyPI version JSON
download
home_pagehttps://github.com/youknowone/methodtools
SummaryExpand standard functools to methods
upload_time2023-02-05 13:17:54
maintainer
docs_urlNone
authorJeong YunWon
requires_python
licenseBSD 2-Clause License
keywords ring functools lru_cache method
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            methodtools
===========

Expand functools features to methods, classmethods, staticmethods and even for
(unofficial) hybrid methods.

For now, methodtools only provides `methodtools.lru_cache`.

Use `methodtools` module instead of `functools` module. Than it will work as
you expected.

.. code:: python

    from methodtools import lru_cache

    class A(object):

        # cached method. the storage lifetime follows `self` object
        @lru_cache()
        def cached_method(self, args):
            ...

        # cached classmethod. the storage lifetime follows `A` class
        @lru_cache()  # the order is important!
        @classmethod  # always lru_cache on top of classmethod
        def cached_classmethod(self, args):
            ...

        # cached staticmethod. the storage lifetime follows `A` class
        @lru_cache()  # the order is important!
        @staticmethod  # always lru_cache on top of staticmethod
        def cached_staticmethod(self, args):
            ...

    @lru_cache()  # just same as functools.lru_cache
    def cached_function():
        ...


Installation
------------

PyPI is the recommended way.

.. sourcecode:: shell

    $ pip install methodtools

To browse versions and tarballs, visit:
    `<https://pypi.python.org/pypi/methodtools/>`_

.. note::
    If you are working on Python 2, install also `functools32`.


See also
--------

- [Documentation](https://methodtools.readthedocs.io/en/latest/)
- This project is derived from `Ring <https://github.com/youknowone/ring/>`_,
  a rich cache interface using the same method handling technique.
- To learn more about bound method dispatching, see also
  [wirerope](https://github.com/youknowone/wirerope).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/youknowone/methodtools",
    "name": "methodtools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ring,functools,lru_cache,method",
    "author": "Jeong YunWon",
    "author_email": "methodtools@youknowone.org",
    "download_url": "https://files.pythonhosted.org/packages/13/3b/c21b74ac17befdf17b286494b02221b7a84affb1d410ff86e38ba0e14b13/methodtools-0.4.7.tar.gz",
    "platform": null,
    "description": "methodtools\n===========\n\nExpand functools features to methods, classmethods, staticmethods and even for\n(unofficial) hybrid methods.\n\nFor now, methodtools only provides `methodtools.lru_cache`.\n\nUse `methodtools` module instead of `functools` module. Than it will work as\nyou expected.\n\n.. code:: python\n\n    from methodtools import lru_cache\n\n    class A(object):\n\n        # cached method. the storage lifetime follows `self` object\n        @lru_cache()\n        def cached_method(self, args):\n            ...\n\n        # cached classmethod. the storage lifetime follows `A` class\n        @lru_cache()  # the order is important!\n        @classmethod  # always lru_cache on top of classmethod\n        def cached_classmethod(self, args):\n            ...\n\n        # cached staticmethod. the storage lifetime follows `A` class\n        @lru_cache()  # the order is important!\n        @staticmethod  # always lru_cache on top of staticmethod\n        def cached_staticmethod(self, args):\n            ...\n\n    @lru_cache()  # just same as functools.lru_cache\n    def cached_function():\n        ...\n\n\nInstallation\n------------\n\nPyPI is the recommended way.\n\n.. sourcecode:: shell\n\n    $ pip install methodtools\n\nTo browse versions and tarballs, visit:\n    `<https://pypi.python.org/pypi/methodtools/>`_\n\n.. note::\n    If you are working on Python 2, install also `functools32`.\n\n\nSee also\n--------\n\n- [Documentation](https://methodtools.readthedocs.io/en/latest/)\n- This project is derived from `Ring <https://github.com/youknowone/ring/>`_,\n  a rich cache interface using the same method handling technique.\n- To learn more about bound method dispatching, see also\n  [wirerope](https://github.com/youknowone/wirerope).\n",
    "bugtrack_url": null,
    "license": "BSD 2-Clause License",
    "summary": "Expand standard functools to methods",
    "version": "0.4.7",
    "split_keywords": [
        "ring",
        "functools",
        "lru_cache",
        "method"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "133bc21b74ac17befdf17b286494b02221b7a84affb1d410ff86e38ba0e14b13",
                "md5": "5b053d748b9199d3594af5508f99bb7b",
                "sha256": "e213439dd64cfe60213f7015da6efe5dd4003fd89376db3baa09fe13ec2bb0ba"
            },
            "downloads": -1,
            "filename": "methodtools-0.4.7.tar.gz",
            "has_sig": false,
            "md5_digest": "5b053d748b9199d3594af5508f99bb7b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3586,
            "upload_time": "2023-02-05T13:17:54",
            "upload_time_iso_8601": "2023-02-05T13:17:54.473701Z",
            "url": "https://files.pythonhosted.org/packages/13/3b/c21b74ac17befdf17b286494b02221b7a84affb1d410ff86e38ba0e14b13/methodtools-0.4.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-05 13:17:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "youknowone",
    "github_project": "methodtools",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "methodtools"
}
        
Elapsed time: 0.04575s