[Datetime-SIG] IANA TZ database statistics

Tim Peters tim.peters at gmail.com
Thu Sep 24 03:22:20 CEST 2015

> ...
> If we can make some simplified assumptions about transition locations and
> sizes, we can avoid a binary search over seconds to locate the transitions
> via POSIX localtime/mktime APIs.

BTW, "the obvious" way to almost always avoid binary search is for a
tzinfo to remember the index of the last transition it had to use,
then next time start a linear search from there.  It should usually
succeed in 1 or 2 tries.  Programs in real life don't jump around
across all possible times at random.

To be truly insane, it could meld linear search with binary search,
like Python's listsort.c's "gallop" functions.  I'd say that's far
more trouble than it's worth in this context, though.  Simple linear
search with a search finger (index saved across searches) should do

More information about the Datetime-SIG mailing list