python-pendulum
pendulum
BlogDocsChangelog

Don't eagerly load the Locale, nor pytest until it's needed.

#926
Comparing
lazyload-or-lazy-create
(
a852f8c
) with
master
(
2982f25
)
CodSpeed Performance Gauge
0%
Untouched
1

Benchmarks

Passed

test_parse_iso8601
tests/benchmarks/test_parse_8601.py
CodSpeed Performance Gauge
0%
14.4 ms14.4 ms

Commits

Click on a commit to change the comparison range
Base
master
2982f25
-0.05%
Don't eagerly load the Locale, nor pytest until it's needed. The main problem here was that importing pendulum.testing.traveller was importing time_machine, which was also importing pytest. And creating the DifferenceFormatter at import time was also loading the locale. Both of these are "optional" in the sense that there is lots you can do in Pendulum without ever using them, so we can relatively straightforwardly delay things until they are requested. Tested by running `uv run --with time_machine -p 3.12 python -Ximporttime -c 'import pendulum'`: - Before: ~50-64ms (a lot of noise) - After: 20-29ms Not a huge slow down, but I figured it was worth it anyway, especially not not load pytest.
a852f8c
4 days ago
by ashb
© 2025 CodSpeed Technology
Home Terms Privacy Docs