On Fri, Oct 18, 2013 at 2:59 PM, Antoine Pitrou <solip...@pitrou.net> wrote: > Is it one stat() call per successful import? Or one stat() call per > sys.path entry?
It's one per finder (i.e. path entry) where a matching name is in the directory (per the finder's cache). So it's a pretty uncommon case with not much overhead when the name is not in the cache. The same thing happens earlier with directories, checking to see if the name was in the cache and *then* checking if it is a directory (_path_isdir). Again, uncommon and otherwise not all that impactful on performance. In the directory case removing the directory check might be inadvisable since it it would result in a _path_isfile call for each registered suffix before moving on (plus it would be incorrectly considered a portion of a potential namespace package). Of course, this is what happens already with directories that have no __init__.<suffix> file in them, which is also an unlikely case that doesn't make much of a difference on performance normally. In the file case I agree that it's much more unlikely that there will be a directory in just the right place with a .py (etc.) suffix in the name. In either case I don't think it saves us much performance-wise, but it may be nice to make that code a simpler if it won't realistically cause anyone headaches. I'm fine with just leaving it as-is. (Also, FTR Brett's email relates to http://bugs.python.org/issue18810.) -eric p.s. I brought up the same point about dir/file checks in http://bugs.python.org/issue19216. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com