On 15 November 2017 at 06:34, Neil Schemenauer <nas-python-ideas@arctrix.com> wrote:
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.

Cheers,
Nick.

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