function calls that may be arbitrarily far-removed from the subject functions or classes decorators are applied oncewhen the subject function or class is definedit' not necessary to add extra code at every call to the class or functionwhich may have to be changed in the future because of both of the prior pointsdecorators make it less likely that user of an api will forget to augment function or class according to api requirements in other wordsbeyond their technical modeldecorators offer some advantages in terms of both code maintenance and consistency moreoveras structuring toolsdecorators naturally foster encapsulation of codewhich reduces redundancy and makes future changes easier decorators do have some potential drawbackstoo--when they insert wrapper logicthey can alter the types of the decorated objectsand they may incur extra calls when used as call or interface proxies on the other handthe same considerations apply to any technique that adds wrapping logic to objects we'll explore these tradeoffs in the context of real code later in this although the choice to use decorators is still somewhat subjectivetheir advantages are compelling enough that they are quickly becoming best practice in the python world to help you decide for yourselflet' turn to the details decorators versus macrospython' decorators bear similarities to what some call aspect-oriented programming in other languages--code inserted to run automatically before or after function call runs their syntax also very closely resembles (and is likely borrowed fromjava' annotationsthough python' model is usually considered more flexible and general some liken decorators to macros toobut this isn' entirely aptand might even be misleading macros ( ' #define preprocessor directiveare typically associated with textual replacement and expansionand designed for generating code by contrastpython' decorators are runtime operationbased upon name rebindingcallable objectsand oftenproxies while the two may have use cases that sometimes overlapdecorators and macros are fundamentally different in scopeimplementationand coding patterns comparing the two seems akin to comparing python' import with #includewhich similarly confuses runtime object-based operation with text insertion of coursethe term macro has been bit diluted over time--to someit now can also refer to any canned series of steps or procedure--and users of other languages might find the analogy to descriptors useful anyhow but they should probably also keep in mind that decorators are about callable objects managing callable objectsnot text expansion python tends to be best understood and used in terms of python idioms decorators