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
ENH: enable timedelta.total_seconds #3616
Conversation
Is the recommended way to run the tests with |
You can pass a name regex on the cmdline. I usually also pass |
Thanks. It looks like this works when I make it a module-level function, but i get compile-time errors when I make it a timedelta method |
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.
Looks like the *_DELTA_*
functions aren't available in Py2. That's probably the reason why they were commented out. It's good to have them declared in the .pxd
file, but we can't use them in code (yet).
makes sense. Is py2 being dropped anytime soon? |
I added the missing declarations for Py2 as a backport. |
8e0b7fd
to
f1f3d99
Compare
Cython/Includes/cpython/datetime.pxd
Outdated
int PyDateTime_DELTA_GET_DAYS(object o) | ||
int PyDateTime_DELTA_GET_SECONDS(object o) | ||
int PyDateTime_DELTA_GET_MICROSECONDS(object o) | ||
int PyDateTime_DELTA_GET_DAYS(timedelta o) | ||
int PyDateTime_DELTA_GET_SECONDS(timedelta o) | ||
int PyDateTime_DELTA_GET_MICROSECONDS(timedelta o) |
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.
Not a good idea. This will enforce type checks on caller side if the type is not known, which will either reduce the performance or make users uglify their input with type casts.
These are clearly macros, designed for speed. Let it crash if users misapply them.
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.
there's not a performance hit to having it be object?
Thanks for walking me through this. Is there a viable way to make total_seconds a timedelta method in addition to a function here? |
No description provided.