@@ -911,6 +911,35 @@ always available. Unless explicitly noted otherwise, all variables are read-only
911911
912912 .. versionadded :: 3.11
913913
914+
915+ .. function :: get_lazy_imports()
916+
917+ Returns the current lazy imports mode as a string.
918+
919+ * ``"normal" ``: Only imports explicitly marked with the ``lazy `` keyword
920+ are lazy
921+ * ``"all" ``: All top-level imports are potentially lazy
922+ * ``"none" ``: All lazy imports are suppressed (even explicitly marked
923+ ones)
924+
925+ See also :func: `set_lazy_imports ` and :pep: `810 `.
926+
927+ .. versionadded :: next
928+
929+
930+ .. function :: get_lazy_imports_filter()
931+
932+ Returns the current lazy imports filter function, or ``None `` if no
933+ filter is set.
934+
935+ The filter function is called for every potentially lazy import to
936+ determine whether it should actually be lazy. See
937+ :func: `set_lazy_imports_filter ` for details on the filter function
938+ signature.
939+
940+ .. versionadded :: next
941+
942+
914943.. function :: getrefcount(object)
915944
916945 Return the reference count of the *object *. The count returned is generally one
@@ -1719,6 +1748,61 @@ always available. Unless explicitly noted otherwise, all variables are read-only
17191748
17201749 .. versionadded :: 3.11
17211750
1751+
1752+ .. function :: set_lazy_imports(mode)
1753+
1754+ Sets the global lazy imports mode. The *mode * parameter must be one of
1755+ the following strings:
1756+
1757+ * ``"normal" ``: Only imports explicitly marked with the ``lazy `` keyword
1758+ are lazy
1759+ * ``"all" ``: All top-level imports become potentially lazy
1760+ * ``"none" ``: All lazy imports are suppressed (even explicitly marked
1761+ ones)
1762+
1763+ This function is intended for advanced users who need to control lazy
1764+ imports across their entire application. Library developers should
1765+ generally not use this function as it affects the runtime execution of
1766+ applications.
1767+
1768+ In addition to the mode, lazy imports can be controlled via the filter
1769+ provided by :func: `set_lazy_imports_filter `.
1770+
1771+ See also :func: `get_lazy_imports ` and :pep: `810 `.
1772+
1773+ .. versionadded :: next
1774+
1775+
1776+ .. function :: set_lazy_imports_filter(filter)
1777+
1778+ Sets the lazy imports filter callback. The *filter * parameter must be a
1779+ callable or ``None `` to clear the filter.
1780+
1781+ The filter function is called for every potentially lazy import to
1782+ determine whether it should actually be lazy. It must have the following
1783+ signature::
1784+
1785+ def filter(importing_module: str, imported_module: str,
1786+ fromlist: tuple[str, ...] | None) -> bool
1787+
1788+ Where:
1789+
1790+ * *importing_module * is the name of the module doing the import
1791+ * *imported_module * is the name of the module being imported
1792+ * *fromlist * is the tuple of names being imported (for ``from ... import ``
1793+ statements), or ``None `` for regular imports
1794+
1795+ The filter should return ``True `` to allow the import to be lazy, or
1796+ ``False `` to force an eager import.
1797+
1798+ This is an advanced feature intended for specialized users who need
1799+ fine-grained control over lazy import behavior.
1800+
1801+ See also :func: `get_lazy_imports_filter ` and :pep: `810 `.
1802+
1803+ .. versionadded :: next
1804+
1805+
17221806.. function :: setprofile(profilefunc)
17231807
17241808 .. index ::
0 commit comments