I am trying to run the script below, and almost every time I run it it prints out the same number twice. I find it hard to believe that not even one nanosecond passes between the creation of the first file and the second file, since the system calls alone should take at least that long! What am I missing? I'm running on Ubuntu using python version 3.5.1+.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
with open("test", 'w') as f:
f.write("hello")
with open("test2", 'w') as f:
f.write("world")
print(os.stat("test").st_mtime_ns)
print(os.stat("test2").st_mtime_ns)
Typical output:
/tmp $ ./mystery.py
1478873526316145825
1478873526316145825