Open
Description
declarative modules with the #[pymodule] mod X {}
syntax is now merged behind the experimental-declarative-modules
syntax (#3815).
The next steps are:
Before v0.21:
- document the new feature in the guide
- allow to export
#[pyclass]
,#[pyfunction]
and#[pymodule]
that are inlined in the modules (in progress in Allow inline struct, enum, fn and mod inside of declarative modules #3902)
Before v0.22:
- properly register submodules in
sys.modules
automatically i.e. fix ModuleNotFoundError: No module named 'supermodule.submodule'; 'supermodule' is not a package #759 by default - allow
#[pymodule_init]
function to return()
orPyResult<()>
- adding a class to a module via the
PyAddToModule
trait is currently relying onPyTypeInfo::type_object_bound
. This function panics when module initialization fail. It would be better to throw an exception instead like inPyModuleMethods::add_class
(in progress in PyAddToModule: Properly propagate initialization error #3919) - investigate relationship between this and "two-phase initialization" e.g. Implement PEP 489 - Multi-phase extension module initialization #2245. In particular we should look at
#[pymodule_data]
as a way to create a per-module data mechanism (might be postpone to later) - allow
#[pymodule_export] const FOO = ...;
to add constants to the modules - investigate automatically filling the
module
parameter of#[pyclass]
usages inside of decarative modules. Automated module= field creation in declarative modules #4213 - remove the
experimental-declarative-modules
feature flag to allow using declarative modules by default - update examples, README and guide
Before v0.23 (or later?):
- Deprecate
#[pyfn]
- Deprecate "function-based" modules