Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 690: Add "per-module opt-in" to "rejected ideas" section #2574

Merged
merged 2 commits into from
May 3, 2022
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
25 changes: 25 additions & 0 deletions pep-0690.rst
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,31 @@ in the common flow.
Rejected Ideas
==============

Per-module opt-in
-----------------

A per-module opt-in using e.g. ``from __future__ import lazy_imports`` has a
couple of disadvantages:

* It is less practical to achieve robust and significant startup-time or
memory-use wins by piecemeal application of lazy imports. Generally it would
require blanket application of the ``__future__`` import to most of the
codebase, as well as to third-party dependencies (which may be hard or
impossible.)

* ``__future__`` imports are not feature flags, they are for transition to
behaviors which will become default in the future. It is not clear if lazy
imports will ever make sense as the default behavior, so we should not
promise this with a ``__future__`` import. Thus, a per-module opt-in would
require a new ``from __optional_features__ import lazy_imports`` or similar
mechanism.

Experience with the reference implementation suggests that the most practical
adoption path for lazy imports is for a specific deployed application to opt-in
globally, observe whether anything breaks, and opt-out specific modules as
needed to account for e.g. reliance on import side effects.


Explicit syntax for lazy imports
--------------------------------

Expand Down