The python docs say
Note: The exact meaning and resolution of the st_atime, st_mtime, and st_ctime attributes depend on the operating system and the file system. For example, on Windows systems using the FAT or FAT32 file systems, st_mtime has 2-second resolution, and st_atime has only 1-day resolution.
However, they go on to imply that st_mtime_ns
has significantly higher resolution:
Similarly, although st_atime_ns, st_mtime_ns, and st_ctime_ns are always expressed in nanoseconds, many systems do not provide nanosecond precision. On systems that do provide nanosecond precision, the floating-point object used to store st_atime, st_mtime, and st_ctime cannot preserve all of it, and as such will be slightly inexact. If you need the exact timestamps you should always use st_atime_ns, st_mtime_ns, and st_ctime_ns.
What is the resolution of st_mtime_ns
?
(X for Y: I need to check if a file has changed since I last ran my program. This means I need to wait until the file's timestamp is at least (resolution) seconds in the past before recording it, so I can detect if it was modified immediately after I looked at it)
source https://stackoverflow.com/questions/72679683/how-accurate-is-st-mtime-ns
Comments
Post a Comment