[Python-Dev] Change PEP 399 import recommendation

Antoine Pitrou solipsis at pitrou.net
Sat Oct 12 23:40:04 CEST 2013


On Sat, 12 Oct 2013 23:35:23 +0200
Christian Heimes <christian at python.org> wrote:
> Am 12.10.2013 19:02, schrieb Antoine Pitrou:
> > If you grow sys.path, imports get slower.
> > (IMHO it also makes the source tree more cumbersome to navigate)
> 
> It shouldn't slow down successful imports. The module finder stops at
> first hit.

You're forgetting that *other* directories can be appended to sys.path
(e.g. the site-packages directories), or any of setuptools' magic
things.

> A directory with pure Python modules is less cumbersome than a couple
> of facade modules or intended code in try/except ImportError blocks.

I don't find it cumbersome to be explicit here. It makes it obvious
what happens. It also makes it extra easy to import the pure Python if
desired (for example for unit tests, or for benchmarking).

Regards

Antoine.


More information about the Python-Dev mailing list