You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-150716: Speed up timedelta construction for integer arguments
timedelta() built its result through PyNumber arithmetic on Python ints
plus two checked_divmod() calls, allocating a dozen temporary objects
and doing a per-call module-state lookup even for the common all-integer
case.
Add delta_new_int_fastpath(): accumulate the total microseconds in a
64-bit integer with overflow guards, then normalize with floor division
and hand the result to the existing new_delta_ex(). Non-exact-int
arguments, 64-bit overflow, and out-of-range day counts fall through to
the unchanged object path, so bool, float, int subclasses (including a
custom __mul__) and bignums keep byte-identical results and errors.
0 commit comments