Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions peps/pep-0810.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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

Expand All @@ -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?
Expand Down