-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
base: main
Are you sure you want to change the base?
Conversation
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary:
- Don't apply automatic style fixes; it bloats the patch and makes it much harder to review
- 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 withint
when usingfloat
becomes impossible. Bonus: It won't make importingdatetime
force you to loadDecimal
in the process (a relatively heavyweight module) - Several comparison and hash functions aren't using the submicrosecond data, so the extra data gets ignored, which seems like a problem.
- You broke pickling. Please don't do that.
- (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 indatetime.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)
This API looks reasonable to me. @tim-one What do you think? |
@SmartManoj I see that you are diligently working on this, but I think that what we lack to solve this issue is not an implementation but rather some decisions about what the interface is going to look like. Feel free to continue working on a proof of concept, but my recommendation here would be to start with a proposal that lays out the unresolved issues with the current designs and how you plan to address them, plus any other details about trade-offs that will need to be made. |
New interface: nanosecond as a keyword argument for backward compatibility. Currently porting out the Python code to C.
cpython/Lib/test/datetimetester.py Lines 1961 to 1985 in 1b7470f
|
Adds nanosecond as a keyword argument for backward compatibility
Solves: #59648