the preceding section illustrated that metaclasses incur an extra step to create the class when used in instance management rolesand hence can' quite subsume decorators in all use cases but what about the inverse--are decorators replacement for metaclassesjust in case this has not yet managed to make your head explodeconsider the following metaclass coding alternative too-- class decorator that returns metaclass instancea decorator can call metaclassthough not vice versa without type(class metaclass(type)def __new__(metaclsnamesupersattrdict)print('in __new__:'print([clsnamesuperslist(attrdict keys())]return type __new__(metaclsnamesupersattrdictdef decorator(cls)return metaclass(cls __name__cls __bases__dict(cls __dict__)class ax @decorator class ( ) def (self)return self self in __new__[' '(,)['__qualname__''__doc__'' '' ''__module__'] xb ( ( xi yi (( this nearly proves the equivalence of the two toolsbut really just in terms of dispatch at class construction time againdecorators essentially serve the same role as metaclass __init__ methods because this decorator returns metaclass instancemetaclasses--or at least their type superclass--are still assumed here moreoverthis winds up triggering an additional metaclass call after the class is createdand isn' an ideal scheme in real code--you might as well move this metaclass to the first creation stepclass (ametaclass=metaclass)same effectbut makes just one class stillthere is some tool redundancy hereand decorator and metaclass roles often overlap in practice and although decorators don' directly support the notion of class-level methods in metaclasses discussed earliermethods and state in proxy objects created by decorators can achieve similar effectsthough for space we'll leave this last observation in the suggested explorations column metaclasses