[Python-ideas] Modules as global namespaces rather than dicts
ncoghlan at gmail.com
Wed Nov 15 01:44:34 EST 2017
On 15 November 2017 at 06:34, Neil Schemenauer <nas-python-ideas at arctrix.com
> So, what is the purpose of all this trouble?
> - I believe quite a lot of Python internals can be simpler. For
> example, importlib is complicated by the fact that a dict is
> passed around when most of the logic would prefer to have the
> module. Grubbing in sys.modules to lookup the module object is
> ugly. The expression "exec(code, module)" is elegant to me.
I like the idea in principle, but highlighting a particular backwards
compatibility pain point: one of the complications in importlib is that we
promise to keep the "sys.modules[__name__] = some_other_object" idiom
working. That means the need to do that check exists regardless of whether
importlib is passing the module itself around, or the module's dict.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas