Decorator

Noun · Development

Definitions

  1. A design pattern or language feature that wraps a function or class to modify its behavior without changing its source code. In Python, decorators use the @syntax to apply higher-order functions. Common uses include logging, caching, authentication, and route registration.

    In plain English: A tag you put above a function that automatically adds extra behavior to it, like gift-wrapping a present with bonus features.

    Example: "I added @cache to the function and response times dropped from 2 seconds to 3 milliseconds. Decorators are magic."

Related Terms