[Python-Dev] PEP 564: Add new time functions with nanosecond resolution (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Mon Oct 16 11:06:31 EDT 2017
- Previous message (by thread): [Python-Dev] PEP 564: Add new time functions with nanosecond resolution
- Next message (by thread): [Python-Dev] PEP 564: Add new time functions with nanosecond resolution
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
On Mon, 16 Oct 2017 12:42:30 +0200 Victor Stinner <victor.stinner at gmail.com> wrote:
time.time()
returns seconds elapsed since the UNIX epoch: January 1st, 1970. This function loses precision since May 1970 (47 years ago)::
This is a funny sentence. I doubt computers (Unix or not) had nanosecond clocks in May 1970.
This PEP adds five new functions to the
time
module:*
time.clockgettimens(clockid)
*time.clocksettimens(clockid, time: int)
*time.perfcounterns()
*time.monotonicns()
*time.timens()
Why not time.process_time_ns()
?
Hardware clock with a resolution better than 1 nanosecond already exists. For example, the frequency of a CPU TSC clock is the CPU base frequency: the resolution is around 0.3 ns for a CPU running at 3 GHz. Users who have access to such hardware and really need sub-nanosecond resolution can easyly extend Python for their needs.
Typo: easily. But how is easy is it?
Such rare use case don't justify to design the Python standard library to support sub-nanosecond resolution.
I suspect that assertion will be challenged at some point :-) Though I agree with the ease of implementation argument (about int64_t being wide enough for nanoseconds but not picoseconds).
Regards
Antoine.
- Previous message (by thread): [Python-Dev] PEP 564: Add new time functions with nanosecond resolution
- Next message (by thread): [Python-Dev] PEP 564: Add new time functions with nanosecond resolution
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]