[Import-SIG] [Python-ideas] My objections to implicit package directories

PJ Eby pje at telecommunity.com
Thu Mar 15 04:24:07 CET 2012


On Tue, Mar 13, 2012 at 5:20 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> Alas, that doesn't work - to avoid slowing down normal startup too much,
> there needs to be a *fast* check that tells the interpreter immediately
> whether or not it is inside a package and needs to search the filesystem
> for the parent of the package directory. That's only possible when each
> package directory has an explicit marker.
>
I'm repeating myself now, but if we are preferring explicit to implict, why
can't we just put the marker in the script itself?  This is actually the
tradeoff made in Perl and Java; you don't have to mark the directory as a
package, but you *do* have to declare the package in the class/module file.

What's more, that explicit declaration could be in the form of a library
call that implements the actual sys.path manipulation -- neatly solving the
performance question and avoiding the need to build the logic into the
interpreter, all in one fell swoop.

(If somebody has already raised a killer objection to this proposal, sorry;
I was not at PyCon.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/import-sig/attachments/20120314/0788a00f/attachment.html>


More information about the Import-SIG mailing list