PEP 844: ``public`` and ``private`` builtins
Python introduces two new builtin functions, public() and private(), to manage module interface visibility. These functions act as decorators to synchronize the __all__ attribute with defined class and function names.
Verified State Diff
Impact & Verification Analysis
Python library maintainers and software developers managing module interfaces.
It improves code maintainability and reduces API surface errors by centralizing visibility declarations, moving away from error-prone manual list management.
Full Fact Overview
PEP 844 addresses the long-standing manual maintenance burden of the __all__ list in Python modules. By implementing @public and @private decorators, developers can declare visibility at the point of definition, reducing the risk of synchronization errors between internal implementation and the exported API surface. The proposal also includes a functional call form for constants or objects that do not support decoration, ensuring comprehensive coverage of module-level exports.