Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
bpo-35723: Proof of concept for tzidx cache #11529
When examining the performance characteristics of pytz, I realized that pytz's eager calculation of tzname, offset and DST gives it an implicit cache that makes it much faster for repeated queries to .utcoffset(), .dst() and/or .tzname(), see my blog post "pytz: The Fastest Footgun in the West", though the eager calculation means that it's slower to create an aware datetime that never calculates those functions.
This proof of concept introduces a "set once" cache to the
I will note that this is currently a WIP, it still needs:
Hm, in an earlier version of this I got a segfault when I had some accidental recursion in the
I suppose for now I'll assume the segfault was for some other reason and that it is fixed now, but if anyone can come up with an example of a tzinfo implemented with recursion that causes a segfault, I'll add and fix it.