Re: [Python-Dev] cpython: Issue 19944: Fix importlib.find_spec() so it imports parents as needed.
On Sat, 25 Jan 2014 23:37:49 +0100 (CET) eric.snow <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/665f1ba77b57 changeset: 88710:665f1ba77b57 user: Eric Snow <ericsnowcurrently@gmail.com> date: Sat Jan 25 15:32:46 2014 -0700 summary: Issue 19944: Fix importlib.find_spec() so it imports parents as needed.
The function is also moved to importlib.util.
Is there a reason to have separate "importlib" (toplevel) and "importlib.util" namespaces? (the doc says "This module contains the various objects that help in the construction of an importer", which doesn't sound related to find_spec()) Regards Antoine.
On Sat, Jan 25, 2014 at 6:28 PM, Antoine Pitrou <solipsis@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. Regarding this changeset, it depended on importlib.util.resolve_name(), so moving find_spec() made sense. We discussed it briefly in issue #19944 and everyone there agreed it was fine.
(the doc says "This module contains the various objects that help in the construction of an importer", which doesn't sound related to find_spec())
We should fix that, :) -eric
On 26 January 2014 11:57, Eric Snow <ericsnowcurrently@gmail.com> wrote:
On Sat, Jan 25, 2014 at 6:28 PM, Antoine Pitrou <solipsis@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. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (3)
-
Antoine Pitrou
-
Eric Snow
-
Nick Coghlan