Title: Subsequent datetime.now() calls return the same datetime · Issue #124832 · python/cpython · GitHub
Open Graph Title: Subsequent datetime.now() calls return the same datetime · Issue #124832 · python/cpython
X Title: Subsequent datetime.now() calls return the same datetime · Issue #124832 · python/cpython
Description: Bug report Bug description: Subsequent datetime.now() may return the same moment in time. from datetime import datetime, UTC now1 = datetime.now(UTC) for i in range(10_000): a = i now2 = datetime.now(UTC) assert now1 < now2 assert now1 <...
Open Graph Description: Bug report Bug description: Subsequent datetime.now() may return the same moment in time. from datetime import datetime, UTC now1 = datetime.now(UTC) for i in range(10_000): a = i now2 = datetime.n...
X Description: Bug report Bug description: Subsequent datetime.now() may return the same moment in time. from datetime import datetime, UTC now1 = datetime.now(UTC) for i in range(10_000): a = i now2 = datetime.n...
Opengraph URL: https://github.com/python/cpython/issues/124832
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Subsequent datetime.now() calls return the same datetime","articleBody":"# Bug report\n\n### Bug description:\n\nSubsequent `datetime.now()` may return the same moment in time.\n\n```python\nfrom datetime import datetime, UTC\n\nnow1 = datetime.now(UTC)\nfor i in range(10_000):\n a = i\nnow2 = datetime.now(UTC)\n\nassert now1 \u003c now2\n```\n```\n assert now1 \u003c now2\n ^^^^^^^^^^^\nAssertionError\n```\n\nThis does seem to work as expected:\n```python\nfrom time import sleep\nfrom datetime import datetime, UTC\n\nnow1 = datetime.now(UTC)\nsleep(0.000_000_001)\nnow2 = datetime.now(UTC)\n\nassert now1 \u003c now2\n```\n\nI'm not sure if this is a bug, but at least it's a documentation issue.\nThere's nothing in the [docs](https://docs.python.org/3/library/datetime.html#datetime.datetime.now) explicitly indicating this behavior.\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-124834\n* gh-125145\n* gh-125146\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/spacemanspiff2007","@type":"Person","name":"spacemanspiff2007"},"datePublished":"2024-10-01T08:27:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/124832/cpython/issues/124832"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:38b341d4-6749-37b6-a3cb-ec8065369934 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BDBE:6F3CF:5CCA13D:827CF1E:6A5012B2 |
| html-safe-nonce | d3b0fa04b3febec3ee4175a592cf2d2c4f6acbbb17eddcfb29a829dda7f00d6b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREJFOjZGM0NGOjVDQ0ExM0Q6ODI3Q0YxRTo2QTUwMTJCMiIsInZpc2l0b3JfaWQiOiIyNjUxMzkzNjY3MzY2OTU5ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 25582ccf8235d52745879115bfae33754a5d6f1a53552fbf0dbbb166345a5fe4 |
| hovercard-subject-tag | issue:2558534421 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/124832/issue_layout |
| twitter:image | https://opengraph.githubassets.com/27c2eeb4da14bc9069dbabb7b4614ae3b2c745263316a2a545c67e32d2f84911/python/cpython/issues/124832 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/27c2eeb4da14bc9069dbabb7b4614ae3b2c745263316a2a545c67e32d2f84911/python/cpython/issues/124832 |
| og:image:alt | Bug report Bug description: Subsequent datetime.now() may return the same moment in time. from datetime import datetime, UTC now1 = datetime.now(UTC) for i in range(10_000): a = i now2 = datetime.n... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | spacemanspiff2007 |
| hostname | github.com |
| expected-hostname | github.com |
| None | fe4f38b24922a1ce81c1708c3793b47c185599b9144ab94f6ca846b00698058d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 42b6390c91978a16f9196c38c7a00e9bf21f37e7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width