[Python-ideas] Module lifecycle: simple alternative to PEP 3121/PEP 489

Nick Coghlan ncoghlan at gmail.com
Fri Apr 15 07:01:49 EDT 2016


On 15 April 2016 at 18:59, Nikita Nemkin <nikita at nemkin.ru> wrote:
> Thanks for your input. I now see how things evolved to the present state.
>
> in the context of PEP 451, my proposal would have been to move
> all default module creation tasks to ModuleType.tp_new (taking
> an optional spec parameter), making separate create and exec
> unnecessary. Too late, I guess.

That doesn't work either, as not only aren't modules in general
actually required to be instances of ModuleType (see [1]), we also
need to be able to create modules to hold __main__, os, sys and
_frozen_importlib before we have an import system to manipulate.

That's a large part of the reason we hived off import-sig from
python-ideas a while back - the import system involves a whole lot of
intertwined arcana stemming from accidents-of-implementation early in
Python's history, as well as the flexible import hook system that was
defined in PEP 302, so a separate list has proven useful for thrashing
out technical details, while we tend to use python-dev and
python-ideas more to check the end result is still comprehensible to
folks that aren't familiar with all those internals :)

Cheers,
Nick.

[1] https://www.python.org/dev/peps/pep-0489/#the-py-mod-create-slot

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list