@@ -2011,8 +2011,8 @@ Files and Directories
20112011 Perform the equivalent of a :c:func: `stat ` system call on the given path.
20122012 (This function follows symlinks; to stat a symlink use :func: `lstat `.)
20132013
2014- The return value is an object whose attributes correspond to the members
2015- of the :c:type: `stat ` structure, namely:
2014+ The return value is an object whose attributes correspond roughly
2015+ to the members of the :c:type: `stat ` structure, namely:
20162016
20172017 * :attr: `st_mode ` - protection bits,
20182018 * :attr: `st_ino ` - inode number,
@@ -2021,10 +2021,18 @@ Files and Directories
20212021 * :attr: `st_uid ` - user id of owner,
20222022 * :attr: `st_gid ` - group id of owner,
20232023 * :attr: `st_size ` - size of file, in bytes,
2024- * :attr: `st_atime ` - time of most recent access,
2025- * :attr: `st_mtime ` - time of most recent content modification,
2026- * :attr: `st_ctime ` - platform dependent; time of most recent metadata change on
2027- Unix, or the time of creation on Windows)
2024+ * :attr: `st_atime ` - time of most recent access expressed in seconds,
2025+ * :attr: `st_mtime ` - time of most recent content modification
2026+ expressed in seconds,
2027+ * :attr: `st_ctime ` - platform dependent; time of most recent metadata
2028+ change on Unix, or the time of creation on Windows, expressed in seconds
2029+ * :attr: `st_atime_ns ` - time of most recent access
2030+ expressed in nanoseconds as an integer,
2031+ * :attr: `st_mtime_ns ` - time of most recent content modification
2032+ expressed in nanoseconds as an integer,
2033+ * :attr: `st_ctime_ns ` - platform dependent; time of most recent metadata
2034+ change on Unix, or the time of creation on Windows,
2035+ expressed in nanoseconds as an integer
20282036
20292037 On some Unix systems (such as Linux), the following attributes may also be
20302038 available:
@@ -2054,6 +2062,14 @@ Files and Directories
20542062 or FAT32 file systems, :attr: `st_mtime ` has 2-second resolution, and
20552063 :attr: `st_atime ` has only 1-day resolution. See your operating system
20562064 documentation for details.
2065+ Similarly, although :attr: `st_atime_ns `, :attr: `st_mtime_ns `,
2066+ and :attr: `st_ctime_ns ` are always expressed in nanoseconds, many
2067+ systems do not provide nanosecond precision. On systems that do
2068+ provide nanosecond precision, the floating-point object used to
2069+ store :attr: `st_atime `, :attr: `st_mtime `, and :attr: `st_ctime `
2070+ cannot preserve all of it, and as such will be slightly inexact.
2071+ If you need the exact timestamps you should always use
2072+ :attr: `st_atime_ns `, :attr: `st_mtime_ns `, and :attr: `st_ctime_ns `.
20572073
20582074 For backward compatibility, the return value of :func: `~os.stat ` is also accessible
20592075 as a tuple of at least 10 integers giving the most important (and portable)
@@ -2081,6 +2097,10 @@ Files and Directories
20812097
20822098 Availability: Unix, Windows.
20832099
2100+ .. versionadded :: 3.3
2101+ The :attr: `st_atime_ns `, :attr: `st_mtime_ns `,
2102+ and :attr: `st_ctime_ns ` members.
2103+
20842104
20852105.. function :: stat_float_times([newvalue])
20862106
0 commit comments