Skip to content

gh-59648: Nanosecond support for datetime #92078

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

Open
wants to merge 163 commits into
base: main
Choose a base branch
from

Conversation

SmartManoj
Copy link

@SmartManoj SmartManoj commented Apr 30, 2022

Adds nanosecond as a keyword argument for backward compatibility

Solves: #59648

@bedevere-bot
Copy link

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
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
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants