Message208828
So those semantics have existed as long as PEP 302 has been around, which is Python 2.3 (that PEP itself is over a decade old), so changing them now would break code.
And honestly I wouldn't change it anyway. On some filesystems, stat calls are extremely costly (e.g. NFS). Even if it was only on failed imports it would still have a cost. And considering a way to stay compatible between Python 2 and 3 is to catch ImportError and then import a module whose named changed, it would still be a costly change.
Now if you personally really want the semantics you are after you could have a sys.meta_path importer which cleared out sys.path_importer_cache and tried the import again.
As for documentation, it's explained in the language reference: http://docs.python.org/3/reference/import.html#path-entry-finders . But otherwise there isn't another place unless someone writes a HOWTO on this, but that probably isn't a good thing as import is something you really should be weary of mucking with. For someone trying to import the contents of a tarfile, they would be better served by a tarfile importer than unpacking the tarfile and then adding a path to sys.path. But someone has to write that tarfile importer first. =) Maybe some day: issue #17630. |
|
Date |
User |
Action |
Args |
2014-01-22 16:55:08 | brett.cannon | set | recipients:
+ brett.cannon, ncoghlan, ezio.melotti, eric.snow, berdario |
2014-01-22 16:55:08 | brett.cannon | set | messageid: <1390409708.8.0.0176437692969.issue20321@psf.upfronthosting.co.za> |
2014-01-22 16:55:08 | brett.cannon | link | issue20321 messages |
2014-01-22 16:55:08 | brett.cannon | create | |
|