The Python Language Reference, Release 3.9.5 (continued from previous page) 42 Chapter 3. Data model >>> classMeta (type): ... def __getattribute__ (*args): ... print("Metaclass getattribute invoked ") ... return type.__getattribute__ (*args) ... >>> classC (object, metaclass =Meta): ... def __len__ (self): ... return 10 ... def __getattribute__ (*args): ... print("Class getattribute invoked ") ... return object.__getattribute__ (*args) ... >>> c =C() >>> c.__len__ () # Explicit lookup via instance Class getattribute invoked 10 >>> type(c) .__len__ (c) # Explicit lookup via type Metaclass getattribute invoked 10 >>> len(c) # Implicit lookup 10 Must return an iterator . Should be used to implement awaitable objects. For instance,$_{asyncio.Future}$ implements this method to be compatible with the$_{await}$expression. New in version 3.5. See also: PEP 492 for additional information about awaitable objects. Note: The generator iterator objects returned from generators decorated with types.coroutine() or asyncio.coroutine() are also awaitable, but they do not implement$_{__await__()}$ . An awaitable object generally implements an __await__() method. Coroutine objects returned from async $_{def}$functions are awaitable. Bypassing the$_{__getattribute__()}$ machinery in this fashion provides significant scope for speed optimisations within the interpreter, at the cost of some flexibility in the handling of special methods (the special method must be set on the class object itself in order to be consistently invoked by the interpreter). In addition to bypassing any instance attributes in the interest of correctness, implicit special method lookup generally also bypasses the$_{__getattribute__()}$ method even of the object’s metaclass: >>> type(int).__hash__ (int)==hash (int) True object. __await__ ( self$_{)}$ 3.4.1 Awaitable Objects 3.4 Coroutines