Skip to content

Decider nanoseconds precision #3773

Open
@dsuch

Description

@dsuch

Hello,

I am reading the SCons 4.0.1 user manual and it advises that Decider('MD5-timestamp') has a time resolution of one second which can cause various unexpected side effects.

I checked the way it is implemented in over at FS.py and I can see that, ultimately, timestamps are compared using os.stat(path).mtime.

Since Python 3.3, though, there is a new attribute called mtime_ns which returns an integer representing the modification time in nanoseconds. The documentation is here.

Naturally, it is up to the filesystem to report it correctly down to a nanosecond but at least ext4 has a resolution much finer than one second (apparently, approximately 10 ns) so I would just suggest to change usage of mtime to mtime_ns to be clear about the intent and to change the wording in the guide slightly to let users know that exact details will depend on the file system in use.

In fact, as far as I can see, mtime alone returns a float rather than an integer and, even it is not in nanoseconds, that float already goes below a one seconds precision.

https://stackoverflow.com/questions/19351867/get-file-modification-time-to-nanosecond-precision

>>> os.stat('.').st_mtime
1381571932.044594
>>> os.stat('.').st_mtime_ns
1381571932044593972

Regards.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions