This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Implementation of the PEP 564: Add time.time_ns()
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: vstinner
Priority: normal Keywords: patch

Created on 2017-10-13 21:34 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3989 merged vstinner, 2017-10-13 21:35
PR 11189 merged vstinner, 2018-12-17 10:42
PR 12287 closed ned.deily, 2019-03-12 09:39
Messages (4)
msg304365 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-13 21:34
time.time() returns time as a float, but the conversion to float lose precision at the nanosecond resolution.

I propose to add a new time.time_ns() function which returns time as an integer number of nanoseconds since epoch. It's similar to the st_mtime_ns field of os.stat_result which extended the old st_mtime field.

For the full rationale, see my thread on python-ideas:
[Python-ideas] Add time.time_ns(): system clock with nanosecond resolution
https://mail.python.org/pipermail/python-ideas/2017-October/047318.html
msg304475 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-16 14:47
> For the full rationale, see my thread on python-ideas: (...)

I just created the PEP 564: "Add new time functions with nanosecond resolution".
msg305426 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-02 14:28
New changeset c29b585fd4b5a91d17fc5dd41d86edff28a30da3 by Victor Stinner in branch 'master':
bpo-31784: Implement PEP 564: add time.time_ns() (#3989)
https://github.com/python/cpython/commit/c29b585fd4b5a91d17fc5dd41d86edff28a30da3
msg332045 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-18 10:45
New changeset 62a68b762a479a72c3defba9ace5f72a0063c5c6 by Victor Stinner in branch 'master':
bpo-31784: Use time.time_ns() in uuid.uuid1() (GH-11189)
https://github.com/python/cpython/commit/62a68b762a479a72c3defba9ace5f72a0063c5c6
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75965
2019-03-12 09:39:13ned.deilysetpull_requests: + pull_request12266
2018-12-18 10:45:17vstinnersetmessages: + msg332045
2018-12-17 10:42:03vstinnersetpull_requests: + pull_request10427
2017-11-02 15:13:05vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-11-02 14:28:30vstinnersetmessages: + msg305426
2017-10-16 14:47:48vstinnersetmessages: + msg304475
2017-10-16 14:46:59vstinnersettitle: Add time.time_ns(): get time with nanosecond resolution -> Implementation of the PEP 564: Add time.time_ns()
2017-10-13 21:35:12vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request3965
2017-10-13 21:34:15vstinnercreate