Skip to content

Commit 7027687

Browse files
avoid creating tuple
1 parent 969e79b commit 7027687

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pandas/_libs/tslibs/timedeltas.pyx

+10-10
Original file line numberDiff line numberDiff line change
@@ -1513,16 +1513,16 @@ class Timedelta(_Timedelta):
15131513
)
15141514
# GH43764, convert any input to nanoseconds first, to ensure any potential
15151515
# nanosecond contributions from kwargs parsed as floats are included
1516-
ns = sum((
1517-
_to_py_int_float(kwargs.get("weeks", 0)) * 7 * 24 * 3600 * 1_000_000_000,
1518-
_to_py_int_float(kwargs.get("days", 0)) * 24 * 3600 * 1_000_000_000,
1519-
_to_py_int_float(kwargs.get("hours", 0)) * 3600 * 1_000_000_000,
1520-
_to_py_int_float(kwargs.get("minutes", 0)) * 60 * 1_000_000_000,
1521-
_to_py_int_float(kwargs.get("seconds", 0)) * 1_000_000_000,
1522-
_to_py_int_float(kwargs.get("milliseconds", 0)) * 1_000_000,
1523-
_to_py_int_float(kwargs.get("microseconds", 0)) * 1_000,
1524-
_to_py_int_float(kwargs.get("nanoseconds", 0)),
1525-
))
1516+
ns = (
1517+
_to_py_int_float(kwargs.get("weeks", 0)) * 7 * 24 * 3600 * 1_000_000_000
1518+
+ _to_py_int_float(kwargs.get("days", 0)) * 24 * 3600 * 1_000_000_000
1519+
+ _to_py_int_float(kwargs.get("hours", 0)) * 3600 * 1_000_000_000
1520+
+ _to_py_int_float(kwargs.get("minutes", 0)) * 60 * 1_000_000_000
1521+
+ _to_py_int_float(kwargs.get("seconds", 0)) * 1_000_000_000
1522+
+ _to_py_int_float(kwargs.get("milliseconds", 0)) * 1_000_000
1523+
+ _to_py_int_float(kwargs.get("microseconds", 0)) * 1_000
1524+
+ _to_py_int_float(kwargs.get("nanoseconds", 0))
1525+
)
15261526
return create_timedelta(ns, "ns", out_reso)
15271527

15281528
if isinstance(value, str) and unit is not None:

0 commit comments

Comments
 (0)