Since decorators are loaded by the interpreter when the module is first read, their usage should be limited to wrappers that can be generically applied. If a decorator is tied to the method's class or to the signature of the function that it enhances, it should be refactored into a regular callable to avoid complexity. Often, it is good practice to group them in dedicated modules that reflect their area of use so that it will be easier to maintain them.
The common patterns for decorators are the following:
- Argument checking
- Caching
- Proxy
- Context provider