[Python-Dev] cpython: Issue 19944: Fix importlib.find_spec() so it imports parents as needed.
ncoghlan at gmail.com
Sun Jan 26 13:04:00 CET 2014
On 26 January 2014 11:57, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> On Sat, Jan 25, 2014 at 6:28 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>> Is there a reason to have separate "importlib" (toplevel) and
>> "importlib.util" namespaces?
> As to why they are separate, you'll need to ask Brett. I believe it's
> meant to keep the top namespace as small as possible.
Correct - the top level namespace is meant for people to use normally
for dynamic imports, reloading modules and clearing the internal
caches when dynamically creating modules.
By contrast, importlib.util is for when people are poking around at
import system internals more directly, writing custom importers and
loaders, replicating parts of the import system, etc. It's a "if you
don't know why you might want these operations, you probably don't
need them" kind of module, so we can keep the top level namespace
simple and relatively easy to learn.
find_loader()/find_spec() are both borderline as to which category
they fall into, but as Eric noted, there was a dependency issue in
this case which meant there were practical benefits to putting
find_spec() in the "import specialist" category.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev