[issue14127] os.stat and os.utime: allow preserving exact metadata

Larry Hastings report at bugs.python.org
Sun Feb 26 16:56:45 CET 2012


Larry Hastings <larry at hastings.org> added the comment:

I suggest that publishing nanoseconds as a plain int would be a nasty API.  Consider what it would do to os.utime:

    if isinstance(mtime, int):
        # must be st_mtime_ns, it's in nanoseconds, use as-is
        value = mtime
    else:
        assert isinstance(mtime, float)
        # must be st_mtime, it's in seconds, multiply by a billion
        value = mtime * 1000000000

Have we ever published an API that treated a parameter as two wildly different numbers based solely on whether the parameter was an int or a float?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14127>
_______________________________________


More information about the Python-bugs-list mailing list