The Python Language Reference, Release 3.9.5 When a new class is created by$_{type.__new__}$ , the object provided as the namespace parameter is copied to a new ordered mapping and the original object is discarded. The new copy is wrapped in a read-only proxy, which becomes the$_{__dict__}$ attribute of the class object. PEP 3135 - New super Describes the implicit __class__ closure reference See also: The potential uses for metaclasses are boundless. Some ideas that have been explored include enum, logging, in- terface checking, automatic delegation, automatic property creation, proxies, frameworks, and automatic resource locking/synchronization. Uses for metaclasses 3.3.4 Customizing instance and subclass checks The following methods are used to override the default behavior of the$_{isinstance()}$ and$_{issubclass()}$ built-in functions. In particular, the metaclass abc.ABCMeta implements these methods in order to allow the addition of Abstract Base Classes (ABCs) as “virtual base classes” to any class or type (including built-in types), including other ABCs. class. __instancecheck__ ( self , instance$_{)}$ Return true if instance should be considered a (direct or indirect) instance of class . If defined, called to imple- ment$_{isinstance(instance, class)}$ . class. __subclasscheck__ ( self , subclass$_{)}$ Return true if subclass should be considered a (direct or indirect) subclass of class . If defined, called to imple- ment$_{issubclass(subclass, class)}$ . Note that these methods are looked up on the type (metaclass) of a class. They cannot be defined as class methods in the actual class. This is consistent with the lookup of special methods that are called on instances, only in this case the instance is itself a class. See also: One can implement the generic class syntax as specified by PEP 484 (for example$_{List[int]}$ ) by defining a special method: This method is looked up on the class object itself, and when defined in the class body, this method is implicitly a class method. Note, this mechanism is primarily reserved for use with static type hints, other usage is discouraged. See also: PEP 560 - Core support for typing module and generic types classmethod object. __class_getitem__ ( cls , key$_{)}$ Return an object representing the specialization of a generic class by type arguments found in key . PEP 3119 - Introducing Abstract Base Classes Includes the specification for customizing$_{isinstance()}$ and issubclass() behavior through$_{__instancecheck__()}$ and$_{__subclasscheck__()}$ , with mo- tivation for this functionality in the context of adding Abstract Base Classes (see the$_{abc}$module) to the language. 3.3.5 Emulating generic types Chapter 3. Data model 36