-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Subsequent datetime.now() calls return the same datetime #124832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Test with Python 3.13, it got better clocks: https://docs.python.org/dev/whatsnew/3.13.html#time
On Python 3.12, it's more likely that two consecutive calls to datetime.now() gives the same microseconds. |
It's not a bug.
What do you expect in the doc? |
I understand and suspected as much.
A warning that due to the clock resolution it's possible that two I had some tests failing which check that a datetime value which was updated was in the future. |
…same instant (#124834) * Update datetime.rst * Update datetime.rst replace warning with note * Update Doc/library/datetime.rst Co-authored-by: Victor Stinner <[email protected]> * Update Doc/library/datetime.rst Co-authored-by: Bénédikt Tran <[email protected]> --------- Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
…n the same instant (pythonGH-124834) * Update datetime.rst * Update datetime.rst replace warning with note * Update Doc/library/datetime.rst Co-authored-by: Victor Stinner <[email protected]> * Update Doc/library/datetime.rst Co-authored-by: Bénédikt Tran <[email protected]> --------- (cherry picked from commit 760b1e1) Co-authored-by: spacemanspiff2007 <[email protected]> Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
…n the same instant (pythonGH-124834) * Update datetime.rst * Update datetime.rst replace warning with note * Update Doc/library/datetime.rst Co-authored-by: Victor Stinner <[email protected]> * Update Doc/library/datetime.rst Co-authored-by: Bénédikt Tran <[email protected]> --------- (cherry picked from commit 760b1e1) Co-authored-by: spacemanspiff2007 <[email protected]> Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
…rn the same instant (GH-124834) (#125145) gh-124832: Add a note to indicate that `datetime.now` may return the same instant (GH-124834) * Update datetime.rst * Update datetime.rst replace warning with note * Update Doc/library/datetime.rst * Update Doc/library/datetime.rst --------- (cherry picked from commit 760b1e1) Co-authored-by: spacemanspiff2007 <[email protected]> Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
…rn the same instant (GH-124834) (#125146) gh-124832: Add a note to indicate that `datetime.now` may return the same instant (GH-124834) * Update datetime.rst * Update datetime.rst replace warning with note * Update Doc/library/datetime.rst * Update Doc/library/datetime.rst --------- (cherry picked from commit 760b1e1) Co-authored-by: spacemanspiff2007 <[email protected]> Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
…n the same instant (python#124834) * Update datetime.rst * Update datetime.rst replace warning with note * Update Doc/library/datetime.rst Co-authored-by: Victor Stinner <[email protected]> * Update Doc/library/datetime.rst Co-authored-by: Bénédikt Tran <[email protected]> --------- Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
Bug report
Bug description:
Subsequent
datetime.now()
may return the same moment in time.This does seem to work as expected:
I'm not sure if this is a bug, but at least it's a documentation issue.
There's nothing in the docs explicitly indicating this behavior.
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
datetime.now
may return the same instant #124834datetime.now
may return the same instant (GH-124834) #125145datetime.now
may return the same instant (GH-124834) #125146The text was updated successfully, but these errors were encountered: