diff --git a/peps/pep-0810.rst b/peps/pep-0810.rst index 74082a734c5..c7b24d78dde 100644 --- a/peps/pep-0810.rst +++ b/peps/pep-0810.rst @@ -440,8 +440,9 @@ referenced the module. It **only** resolves the lazy object being accessed. Accessing a lazy object (from a global variable or a module attribute) reifies the object. Accessing a module's ``__dict__`` reifies **all** lazy objects in -that module. Operations that indirectly access ``__dict__`` (such as -:func:`dir`) also trigger this behavior. +that module. Calling ``dir()`` at the global scope will not reify the globals +and calling ``dir(mod)`` will be special cased in ``mod.__dir__`` avoid +reification as well. Example using ``__dict__`` from external code: @@ -1329,9 +1330,8 @@ How do lazy imports interact with ``dir()``, ``getattr()``, and module introspec ------------------------------------------------------------------------------------- Accessing lazy imports through normal attribute access or ``getattr()`` -will trigger reification. Calling ``dir()`` on a module will reify all lazy -imports in that module to ensure the directory listing is complete. This is -similar to accessing ``mod.__dict__``. +will trigger reification of the accessed attribute. Calling ``dir()`` on a +module will be special cased in ``mod.__dir__`` to avoid reification. .. code-block:: python @@ -1343,7 +1343,6 @@ similar to accessing ``mod.__dict__``. # Any of these trigger reification: dumps_func = json.dumps dumps_func = getattr(json, 'dumps') - dir(json) # Now json is in sys.modules Do lazy imports work with circular imports?