@@ -440,8 +440,9 @@ referenced the module. It **only** resolves the lazy object being accessed.
440440
441441Accessing a lazy object (from a global variable or a module attribute) reifies
442442the object. Accessing a module's ``__dict__ `` reifies **all ** lazy objects in
443- that module. Operations that indirectly access ``__dict__ `` (such as
444- :func: `dir `) also trigger this behavior.
443+ that module. Calling ``dir() `` at the global scope will not reify the globals
444+ and calling ``dir(mod) `` will be special cased in ``mod.__dir__ `` avoid
445+ reification as well.
445446
446447Example using ``__dict__ `` from external code:
447448
@@ -1329,9 +1330,8 @@ How do lazy imports interact with ``dir()``, ``getattr()``, and module introspec
13291330-------------------------------------------------------------------------------------
13301331
13311332Accessing lazy imports through normal attribute access or ``getattr() ``
1332- will trigger reification. Calling ``dir() `` on a module will reify all lazy
1333- imports in that module to ensure the directory listing is complete. This is
1334- similar to accessing ``mod.__dict__ ``.
1333+ will trigger reification of the accessed attribute. Calling ``dir() `` on a
1334+ module will be special cased in ``mod.__dir__ `` to avoid reification.
13351335
13361336.. code-block :: python
13371337
@@ -1343,7 +1343,6 @@ similar to accessing ``mod.__dict__``.
13431343 # Any of these trigger reification:
13441344 dumps_func = json.dumps
13451345 dumps_func = getattr (json, ' dumps' )
1346- dir (json)
13471346 # Now json is in sys.modules
13481347
13491348 Do lazy imports work with circular imports?
0 commit comments