Skip to content

Commit 6257147

Browse files
committed
PERF: shortcut the positional arguments check for a 10% performance gain
1 parent 9aa0187 commit 6257147

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/_libs/tslibs/timestamps.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,8 @@ class Timestamp(_Timestamp):
15361536
# check that the second argument is an int.
15371537
#
15381538
# - Nones for the first four (legacy) arguments indicate pydatetime
1539-
# keyword arguments. year, month, and day are required. As a
1540-
# shortcut, we just check that the first argument was not passed.
1539+
# keyword arguments. year, month, and day are required. We just
1540+
# check that no positional arguments were passed.
15411541

15421542
cdef:
15431543
object ts_input=_no_input
@@ -1574,7 +1574,7 @@ class Timestamp(_Timestamp):
15741574
ts_input = args[0]
15751575
tzinfo = kwargs.get("tzinfo")
15761576
# Building from positional arguments
1577-
elif 9 > args_len > 2 and all(isinstance(arg, int) for arg in args[:3]):
1577+
elif 9 > args_len > 2 and isinstance(args[1], int):
15781578
args = args + (None,) * (8 - args_len)
15791579
year, month, day, hour, minute, second, microsecond, tzinfo = args
15801580

0 commit comments

Comments
 (0)