[Datetime-SIG] Are there any "correct" implementations of tzinfo?
random832 at fastmail.com
Mon Sep 14 23:53:55 CEST 2015
On Mon, Sep 14, 2015, at 17:34, Tim Peters wrote:
> Yes, we "could have" done that for all pickle formats for all types.
> But why on Earth would we? Pickle size is important to many apps
> (e.g., Zope applications can store billions of pickles in databases.
> and it may not be purely coincidence ;-) that Zope Corp paid for
> datetime development), and there would have been loud screaming about
> any "wasted" bytes.
Would allowing a 16-byte string in the future have increased the storage
occupied by a 10-byte string today? Would allowing a third argument in
the future have increased the storage occupied by two arguments today?
As far as I can tell the pickle format for non-primitive types isn't
> > That you didn't makes me wonder just where you're finding the space to put the
> > fold bit.
> PEP 495 gives all the details. Short course: there are bits that are
> _always_ 0 now within some datetime pickle bytes. `fold` will abuse
> one of those always-0-now pickle bits.
And what happens to older implementations if that bit is 1?
> Aware datetimes _within_ a zone also follow the naive time model.
> It's unfortunate that they're nevertheless called "aware" datetimes.
> So, sorry, even when sorting a list of aware datetimes, if they share
> a common zone it is wholly intended that they all work in naive time.
And if some of them share a common zone, then some of them will work in
naive time, and some of them will work in aware time, and some pairs
(well, triples) of them will cause problems for sort/bisect algorithms.
Maybe it'd be best to simply ban interzone comparisons. Or have some
sort of context manager to determine how arithmetic and comparisons
More information about the Datetime-SIG