One of my favorite parts about Python is how we can get insight to the language’s evolution through the Python Enhancement Proposals. Rather than having to dig through mailing list archives, debates over new features and changes are conveniently summarized and updated as web pages.
For example, PEP 0495 – Local Time Disambiguation, is a great reminder of how difficult time is, in human and computational terms. This particular PEP will be implemented in Python 3.6 and concerns adding a new attribute called
fold to the
fold? In timezones that use Daylight Savings Time – i.e. when a day “jumps back” an hour – the times between 1 and 2 AM technically happen twice. The
fold attribute is, by default, set to
0. But when it is set to
1, it means that the datetime object represents the second occurrence of a time, e.g.
1:30AM after the jump back has happened.
Why call it “fold”, rather than something that sounds specifically related to Daylight Savings Time? The genericness of the name is intended:
Suggested by Guido van Rossum and favored by one (but initially disfavored by another) author. A consensus was reached after the allowed values for the attribute were changed from False/True to 0/1. The noun “fold” has correct connotations and easy mnemonic rules, but at the same time does not invite unbased assumptions.
The non-technical example is very helpful in showing how describing “fold” in terms of DST is inherently confusing:
Alice: Bob - let’s have a stargazing party at 01:30 AM tomorrow! Bob: Should I presume initially that Daylight Saving Time is or is not in effect for the specified time? Alice: Huh?
And here’s the same discussion, except with the matter simplified as “first or second?”:
Bob: Alice - let’s have a stargazing party at 01:30 AM tomorrow! Alice: You know, Bob, 01:30 AM will happen twice tomorrow. Which time do you have in mind? Bob: I did not think about it, but let’s pick the first.
The entire discussion of what
fold should be called, what values it should have, and what its default value should be – plus, how it would interpolate with all
< 3.6 versions of
datetime – is a very readable discussion about how to properly name things in the least confusing way. And yet, it will still be confusing, because of how complicated time is in general, and of how humans interpret words.
Hence, why “naming things” is rightly considered one of the two hardest problems in computer science.