This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Expose mtime check in importlib.machinery.FileFinder
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.4
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon
Priority: normal Keywords: patch

Created on 2013-08-22 14:42 by brett.cannon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
OO_os.diff brett.cannon, 2013-11-01 18:08 review
Messages (2)
msg195898 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-08-22 14:42
If you have enough control over your environment you really don't need to waste a stat call checking if the directory has been modified. That makes the idea of having the check of whether the directory has changed be exposed publicly a useful idea (code:

Maybe a check_mtime(old_mtime) where we guarantee that old_mtime is negative if this is the first check? That way the _path_mtime stays private but the check itself is exposed for people to do things like
``return 0`` so that the cache is built once on first use of find_loader() but otherwise never re-calculated.
msg201927 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-11-01 18:08
So I tried extracting out the check by implementing a path_mtime() method on FileFinder, but then I realized it would simply be easier to abstract out _os.stat() to _path_stat() and let people cache stat calls at the global level, which would have a side-effect of never refreshing the path cache. Otherwise all of the other experiments I tried with minimizing stat calls didn't buy me much according to the benchmarks.

I have also attached a patch which abstracts all file system code that passed through _os into a class. It didn't buy me much plus added a little overhead thanks to the extra abstraction, so I did not bother to commit it.
Date User Action Args
2022-04-11 14:57:49adminsetgithub: 63009
2013-11-01 18:08:06brett.cannonsetstatus: open -> closed
files: + OO_os.diff
messages: + msg201927

keywords: + patch
resolution: rejected
2013-11-01 15:30:22brett.cannonlinkissue19473 superseder
2013-08-22 14:42:47brett.cannonsettype: enhancement
stage: test needed
2013-08-22 14:42:33brett.cannoncreate