Skip to content

gh-59648: Nanosecond support for datetime#92078

Open
SmartManoj wants to merge 163 commits intopython:mainfrom
SmartManoj:patch-4
Open

gh-59648: Nanosecond support for datetime#92078
SmartManoj wants to merge 163 commits intopython:mainfrom
SmartManoj:patch-4

Conversation

@SmartManoj
Copy link
Copy Markdown

@SmartManoj SmartManoj commented Apr 30, 2022

Adds nanosecond as a keyword argument for backward compatibility

Solves: #59648

@bedevere-bot
Copy link
Copy Markdown

Every change to Python requires a NEWS entry.

Please, add it using the blurb_it Web app or the blurb command-line tool.

Copy link
Copy Markdown
Contributor

@MojoVampire MojoVampire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary:

  1. Don't apply automatic style fixes; it bloats the patch and makes it much harder to review
  2. Using Decimal the way you're using it is inherently unsafe due to unknown contextual precision, and will make the code slower to boot. Find a way to do your work with int when using float becomes impossible. Bonus: It won't make importing datetime force you to load Decimal in the process (a relatively heavyweight module)
  3. Several comparison and hash functions aren't using the submicrosecond data, so the extra data gets ignored, which seems like a problem.
  4. You broke pickling. Please don't do that.
  5. (A biggy I couldn't comment on inline) This only changes the Python level datetime module, that CPython itself doesn't even use, by and large. Any change to the Python level code in datetime.py requires a complementary change in _datetimemodule.c so the C accelerated version of the module has the same behavior (you may have avoided at least a few test failures because they were testing the C module and didn't notice the broken code in the Python module)

@rhettinger
Copy link
Copy Markdown
Contributor

This API looks reasonable to me. @tim-one What do you think?

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants