{"id":13469213,"url":"https://github.com/lord63/awesome-python-decorator","last_synced_at":"2025-12-30T16:24:13.532Z","repository":{"id":4256629,"uuid":"52526929","full_name":"lord63/awesome-python-decorator","owner":"lord63","description":"A curated list of awesome python decorator resources.","archived":false,"fork":false,"pushed_at":"2024-06-13T17:23:07.000Z","size":20,"stargazers_count":734,"open_issues_count":4,"forks_count":68,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-10-29T23:54:45.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lord63.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-25T13:39:09.000Z","updated_at":"2024-10-28T15:26:11.000Z","dependencies_parsed_at":"2024-11-09T05:01:44.594Z","dependency_job_id":"c469ba73-ca30-48e4-b588-e5f2b3f4a862","html_url":"https://github.com/lord63/awesome-python-decorator","commit_stats":{"total_commits":25,"total_committers":4,"mean_commits":6.25,"dds":"0.16000000000000003","last_synced_commit":"18c6976978c11579c8dd70d87b33f09d0be96c4e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lord63%2Fawesome-python-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lord63%2Fawesome-python-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lord63%2Fawesome-python-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lord63%2Fawesome-python-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lord63","download_url":"https://codeload.github.com/lord63/awesome-python-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245258156,"owners_count":20585977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T15:01:29.367Z","updated_at":"2025-12-30T16:24:13.491Z","avatar_url":"https://github.com/lord63.png","language":null,"readme":"# Awesome Python Decorator\n\n\u003e A curated list of awesome python decorator resources.\n\n## You don't know decorator\n\nHere are some resources about the python decorators.\n\n- [PEP 0318 -- Decorators for Functions and Methods](https://www.python.org/dev/peps/pep-0318/)\n- [PEP 3129 -- Class Decorators](https://www.python.org/dev/peps/pep-3129/)\n- [Python Wiki - PythonDecorators](https://wiki.python.org/moin/PythonDecorators) This page largely documents the\nhistory of the process of adding decorators to Python.\n- [Python Wiki - PythonDecoratorLibrary](https://wiki.python.org/moin/PythonDecoratorLibrary) This page is meant\nto be a central repository of decorator code pieces. Lots of decorator examples, really cool!\n\n## Built-in python decorator\n\n- [@abc.abstractmethod](https://docs.python.org/3.5/library/abc.html#abc.abstractmethod) A decorator indicating\nabstract methods.\n- [@abc.abstractproperty](https://docs.python.org/3.5/library/abc.html#abc.abstractproperty) A subclass of the built-in\n`property()`, indicating an abstract property.\n- [@asyncio.coroutine](https://docs.python.org/3.5/library/asyncio-task.html#asyncio.coroutine) Decorator to mark\ngenerator-based coroutines. New in version 3.4.\n- [@atexit.register](https://docs.python.org/2.7/library/atexit.html#atexit.register) Register func as a function to\nbe executed at termination.\n- [@classmethod](https://docs.python.org/3.5/library/functions.html#classmethod) Return a class method for function.\n- [@contextlib.contextmanager](https://docs.python.org/3.5/library/contextlib.html#contextlib.contextmanager) Define a\nfactory function for with statement context managers, without needing to create a class or separate `__enter__()` and\n`__exit__()` methods.\n- [@functools.cached_property](https://docs.python.org/3.8/library/functools.html#functools.cached_property) Transform\na method of a class into a property whose value is computed once and then cached as a normal attribute\nfor the life of the instance.\n- [@functools.lru_cache](https://docs.python.org/3.5/library/functools.html#functools.lru_cache) Decorator to wrap a\nfunction with a memoizing callable that saves up to the maxsize most recent calls. It can save time when an expensive\nor I/O bound function is periodically called with the same arguments. New in python 3.2.\n- [@functools.singledispatch](https://docs.python.org/3.5/library/functools.html#functools.singledispatch) Transforms\na function into a single-dispatch generic function. New in python 3.4.\n- [@functools.total_ordering](https://docs.python.org/3.5/library/functools.html#functools.total_ordering) Given a\nclass defining one or more rich comparison ordering methods, this class decorator supplies the rest.\n- [@functools.wraps](https://docs.python.org/3.5/library/functools.html#functools.wraps) This is a convenience function\nfor invoking update_wrapper() as a function decorator when defining a wrapper function.\n- [@property](https://docs.python.org/3.5/library/functions.html#property) Return a property attribute.\n- [@staticmethod](https://docs.python.org/3.5/library/functions.html#staticmethod) Return a static method for function.\n- [@types.coroutine](https://docs.python.org/3.5/library/types.html#types.coroutine) This function transforms a\ngenerator function into a coroutine function which returns a generator-based coroutine. New in python 3.5.\n- [@unittest.mock.patch](https://docs.python.org/3.5/library/unittest.mock.html#unittest.mock.patch) Acts as a function\ndecorator, class decorator or a context manager. Inside the body of the function or with statement, the target is\npatched with a new object. When the function/with statement exits the patch is undone. New in python 3.3.\n- [@unittest.mock.patch.dict](https://docs.python.org/3.5/library/unittest.mock.html#unittest.mock.patch.dict)\nPatch a dictionary, or dictionary like object, and restore the dictionary to its original state after the test.\nNew in python 3.3.\n- [@unittest.mock.patch.multiple](https://docs.python.org/3.5/library/unittest.mock.html#unittest.mock.patch.multiple)\nPerform multiple patches in a single call. New in python 3.3.\n- [@unittest.mock.patch.object](https://docs.python.org/3.5/library/unittest.mock.html#unittest.mock.patch.object)\nPatch the named member (attribute) on an object (target) with a mock object. New in python 3.3.\n- to be continue\n\n\n## Python decorator in the wild\n\nOnce you know the basics of how to use a decorator, you can take a look at some real projects to see how people use\ndecorators in real life.\n\n- [cached-property](https://github.com/pydanny/cached-property) A decorator for caching properties in classes.\n- [cachetools](https://github.com/tkem/cachetools) This module provides various memoizing collections and decorators,\nincluding variants of the Python 3 Standard Library @lru_cache function decorator.\n- [celery](https://github.com/celery/celery) Celery is a distributed task queue, it uses decorator to create tasks.\n- [click](https://github.com/mitsuhiko/click) Click is a Python package for creating beautiful command line interfaces,\nbased on declaring commands through decorators. You can also check out the\n[autocommand](https://github.com/Lucretiel/autocommand) library which shares a similar idea with click.\n- [deco](https://github.com/alex-sherman/deco) A simplified parallel computing model for Python. DECO automatically\nparallelizes Python programs, and requires minimal modifications to existing serial programs.\n- [decorator](https://github.com/micheles/decorator) This is your best option if you want to preserve the signature of\ndecorated functions in a consistent way across Python releases.\n- [deprecated](https://github.com/tantale/deprecated) Use `@deprecated` decorator to deprecate old python classes,\n  functions or methods. Decorators can also be used to add Sphinx directives.\n- [fasteners](https://github.com/harlowja/fasteners) Provides useful locks and decorators to lock/unlock around functions and methods.\n- [flask](https://github.com/mitsuhiko/flask) Flask is a micro web framework in python, which uses decorators to route\nthe URL, register error handler, register processor and so on.\n- [flask-login](https://github.com/maxcountryman/flask-login) Flask-Login provides user session management for Flask.\nFor example, it use the `login_required` decorator to protect some views that need the user to be logged in.\n- [GB2260.py](https://github.com/cn/GB2260.py) This project is used to look up Chinese administrative divisions. It\nuses decorators to write Python 2.x and 3.x compatible code.\n- [marshmallow](https://github.com/marshmallow-code/marshmallow) A lightweight library for converting complex objects\nto and from simple Python datatypes. It use decorators to register schema pre-processing and post-processing methods.\n- [me-api](https://github.com/lord63/me-api) An extensible, personal API with custom integrations. It uses a decorator\nto make sure there is an access_token in the configuration file before sending the API request and reject another\nauthentication if there is already an access_token.\n- [numba](https://numba.pydata.org/) Numba gives you the power to speed up your applications with high performance functions written directly in Python. It uses `jit` to decorate array-oriented and math-heavy Python code can be just-in-time compiled to native machine instructions, similar in performance to C, C++ and Fortran, without having to switch languages or Python interpreters.\n- [lettuce](https://github.com/gabrielfalcao/lettuce) Lettuce is a BDD tool for python. It uses `step` and `steps` to\ndecorate functions and classes so they become new step definitions.\n- [profilehooks](https://github.com/mgedmin/profilehooks) Python decorators for profiling/tracing/timing a single\nfunction.\n- [pypi-cli](https://github.com/sloria/pypi-cli) pypi-cli is a command-line interface to the Python Package Index.\nIt use decorator to makes a property lazy-evaluated.\n- [py-spin](https://github.com/lord63/py-spin) py-spin is a terminal spinner package for python. Yes, it does use a\ndecorator to register a function that needs to take a long time to finish, as well as showing a spinner while it's\nprocessing!\n- [python-goto](https://github.com/snoack/python-goto) A function decorator that rewrites the bytecode, enabling goto\nin python.\n- [showme](https://github.com/kennethreitz/showme) ShowMe is a simple set of extremely useful function decorators for Python.\nIt allows you to view trace information, execution time, cputime, and function documentation.\n- [tenacity](https://github.com/jd/tenacity) Simplifies the task of adding retry behavior to just about anything. It originates from a fork of [retrying](https://github.com/rholder/retrying).\n- [timeout-decorator](https://github.com/pnpnpn/timeout-decorator) Timeout decorator for Python which uses a decorator\nto limit the execution time of the given function.\n- [Tomorrow](https://github.com/madisonmay/Tomorrow) Tomorrow use decorator to do the magic that let you write\nasynchronous code with ease.\n- [wrapt](https://github.com/GrahamDumpleton/wrapt) A Python module for decorators, wrappers and monkey patching.\n\n## Contribute\n\nPlease do! Create a project is not hard, while maintaining it is not easy. To make this project stay healthy and easy\nto maintain, what's more, to make it to be AWESOME, we need help. The best way in my opinion is watch this repository\nand join the daily discussions when some send a pull request and raise an issue. There are also many other ways to\ndo the contribution, but please read the [Contributing guide][] before stepping forward :)\n\nContributions are always welcome at any time! :sparkles: :cake: :sparkles:\n\n## License\n\nCC0 1.0\n\n[Contributing guide]: https://github.com/lord63/awesome-python-decorator/blob/master/CONTRIBUTING.md\n","funding_links":[],"categories":["Misc","Others","Programming Languages","Programming Language","Other Lists","Awesome awesomeness"],"sub_categories":["JavaScript","TeX Lists","Awesome python"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flord63%2Fawesome-python-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flord63%2Fawesome-python-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flord63%2Fawesome-python-decorator/lists"}