osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implement C's Switch in Python 3


On Mon, Feb 4, 2019 at 8:02 AM Bob van der Poel <bob at mellowood.ca> wrote:
>
> I'm surprised that no one has yet addressed the year 10000 problem. Hopefully we're doing numeric, not alpha sorts on the stuff before the 1st '-'. And, the compact versions will really screw up :).
>

Compact versions? You mean non-delimited dates? They sort just fine numerically:

20190204
99991231
100000101

They also sort just fine if you add a two-digit serial number:

2017081702
2017120801
2019011300

and while it's true that this format will overflow in two thousand
years if stored in a 32-bit number, it's fine for arbitrary future
dates if stored in bignums.

ChrisA