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 |
scoder
left a comment
There was a problem hiding this comment.
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.
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.
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.