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
Define _PyTime_MIN/MAX with macros specific to the actual type of _PyTime_t #15384
Conversation
Thanks for the PR @sir-sigurd.
This looks like a minor enough adjustment to warrant a skip issue
and skip news
, particularly since it's modifying internal constants. I'll notify the datetime experts (although this might not be needed, since they were automatically added as reviewers).
It's not clear to me:
The principle of Chesterton's Fence applies here, so I think we need to figure out whether this was actually a mistake or a deliberate choice. Looks like @vstinner added these macros in this commit. Maybe he can comment as to why he chose |
There is no secret: it's a bug :-) I don't recall the detail, but I recall that I wasn't sure about if using int64_t would cause any portability issue. There were very old discussions about using <stdint.h> and why PY_LONG_LONG was needed, etc. I chose to attempt to use int64_t and see who is going to complain. Years later: nobody complains, so it seems like the (Python) World is ready for int64_t :-D Maybe the first iteration of my change used "typedef long _PyTime_t;" and then I changed my mind. |
Thanks @sir-sigurd for the PR, and @vstinner for merging it |
Sorry @sir-sigurd and @vstinner, I had trouble checking out the |
GH-15425 is a backport of this pull request to the 3.7 branch. |
_PyTime_t type is defined as int64_t, and so min/max are INT64_MIN/INT64_MAX, not PY_LLONG_MIN/PY_LLONG_MAX. (cherry picked from commit 8e76c45) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
If you are curious about _PyTime API, I wrote two articles about its history :-) |
GH-15426 is a backport of this pull request to the 3.8 branch. |
_PyTime_t type is defined as int64_t, and so min/max are INT64_MIN/INT64_MAX, not PY_LLONG_MIN/PY_LLONG_MAX. (cherry picked from commit 8e76c45) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
@vstinner Thanks for the detailed explanation and context!
Are there still any use cases for |
long long is now always avaialble and PY_LONG_LONG is always defined as "long long". The macro is no more used in the Python code base, except in dict_get_version() of _testcapimodule.c. Maybe this function can be updated. |
@vstinner I've been looking to get more experience with C-API development, perhaps this would serve as a decent introductory project for me to work on. |
@aeros167 there is already #15386. |
Ah okay, thanks for letting me know. |
_PyTime_t type is defined as int64_t, and so min/max are INT64_MIN/INT64_MAX, not PY_LLONG_MIN/PY_LLONG_MAX.
_PyTime_t type is defined as int64_t, and so min/max are INT64_MIN/INT64_MAX, not PY_LLONG_MIN/PY_LLONG_MAX.
_PyTime_t type is defined as int64_t, and so min/max are INT64_MIN/INT64_MAX, not PY_LLONG_MIN/PY_LLONG_MAX.
No description provided.