Choosing the fastest datetime library for Python

Pythonperformancebenchmarkingdatetime

523 Words

2026-09-29 00:00 +0000


Python has several popular datetime libraries: the standard-library datetime, python-dateutil, Arrow, Pendulum, udatetime, Whenever, plus parsing functionality in Pydantic and pandas.

If performance matters, which one should you use?

The benchmark-datetime project compares three kinds of operations:

  • parsing datetime values
  • manipulating dates and times
  • dumping datetime values to strings

The current benchmark runs on Python 3.14.7 and compares libraries only where the operation is supported and relevant.

The short answer is: Whenever is the fastest option in 10 of the 12 benchmark groups.

Whenever is usually the fastest

For adding a duration:

LibraryMean time
Whenever387 ns
datetime976 ns
Pendulum4.53 µs
Arrow8.04 µs

For getting the current local time:

LibraryMean time
Whenever95.3 ns
udatetime121 ns
datetime170 ns
Pendulum974 ns
Arrow3.25 µs

For dumping a datetime to ISO format:

LibraryMean time
Whenever119 ns
udatetime424 ns
datetime1.05 µs
Arrow1.08 µs
Pendulum1.54 µs

The same pattern appears across most of this benchmark suite: Whenever has noticeably lower overhead than the alternatives in these tests.

Parsing shows the biggest differences

ISO 8601 parsing is especially interesting:

LibraryMean time
Whenever89.6 ns
datetime.fromisoformat()103 ns
Pydantic399 ns
udatetime512 ns
pandas2.74 µs
python-dateutil4.64 µs
Pendulum4.96 µs
Arrow33.9 µs

Here, the standard library is almost as fast as Whenever.

Arrow is hundreds of times slower in this particular benchmark because arrow.get() is a more general parsing interface, while datetime.fromisoformat() and OffsetDateTime.parse_iso() are specialized APIs.

That distinction matters: the benchmark measures the actual API call used for the operation, not some abstract notion of library speed.

The exceptions are useful

Whenever does not win every benchmark.

For a weekday lookup, Python’s datetime and udatetime take about 58 ns, while Whenever takes about 172 ns.

The reason is simple: datetime exposes .weekday() directly. Whenever needs a longer call chain to produce the same 0–6 numbering:

dt.date().day_of_week().value - 1

ISO 8601 duration parsing is another exception. Pydantic takes about 352 ns, while Whenever takes about 4.73 µs because it first parses an ItemizedDelta and then converts it to TimeDelta.

These cases show why one overall score would be misleading. API design affects performance too.

What should you choose?

If raw datetime performance is important, Whenever is the strongest option in this benchmark.

But datetime remains very competitive, especially for ISO 8601 parsing and simple operations, and it requires no extra dependency.

Arrow and Pendulum provide higher-level APIs and are slower in many of these benchmarks. Choosing them for that convenience can be a reasonable trade-off when datetime operations are not a bottleneck.

Pydantic and pandas should generally be chosen for their broader functionality rather than as standalone datetime libraries, although their existing datetime APIs may be useful when those packages are already dependencies.

A practical approach is:

  • Use datetime if it already does what is needed.
  • Consider Whenever when datetime operations are performance-sensitive.
  • When using Arrow, Pendulum, Pydantic, or pandas for their functionality, benchmark the specific relevant operations rather than treating the whole library as fast or slow.

The full benchmark results, source code, and histograms are available in benchmark-datetime.