[New-bugs-announce] [issue11457] Expose nanosecond precision from system calls
report at bugs.python.org
Thu Mar 10 01:05:28 CET 2011
New submission from Kris Henriksson <kthenriksson at gmail.com>:
The most recent (issue 7) release of the POSIX standard mandates support for nanosecond precision in certain system calls. For example, the stat structure include a timespec struct for each of mtime, atime, and ctime that provides such nanosecond precision. There is also an futimens call that allows setting the time accurate to the nanosecond. Support for such precision is available at the least on 2.6 Linux kernels.
Currently, the Python float type is used everywhere to express times in a single value (such as the result from os.stat). However, since this is implemented in CPython using type double (and possibly similarly elsewhere) it is impossible to obtain sufficient precision using a float.
Therefore, it would be useful to expose the number of seconds and nanoseconds separately
to allow full precision. Perhaps adding these values as additional members to the return value from os.stat would be most useful, something like .st_atimensec that Linux sometimes uses, or else just follow the POSIX standard to include a sub-struct.
This is important for example with the tarfile module with the pax tar format. The POSIX tar standard mandates storing the mtime in the extended header (if it is not an integer) with as much precision as is available in the underlying file system, and likewise to restore this time properly upon extraction. Currently this is not possible.
components: Library (Lib)
title: Expose nanosecond precision from system calls
type: feature request
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce