On 01/09/2014 06:57 AM, Chris Angelico wrote:
On Fri, Jan 10, 2014 at 1:14 AM, Roy Smith <r...@panix.com> wrote:


Thanks for this collection! Now we can discuss.

[snip]

Datetimes are self-describing.  If I have a datetime or a timedelta, I
know what I've got.  I've written more than one bug where I assumed a
number somebody handed me was in seconds but it turned out to be in ms.
That can never happen with a timedelta.  We do a lot of stuff in
javascript, where times are ms, so this is a common problem for us.

Sure. Though that's no different from other cases where you need
out-of-band information to understand something, as we've just been
discussing in the threads about text handling - if you have a puddle
of bytes, you can't decode them to text without knowing what the
encoding is. [1] If your data's coming from JS, it won't be a
timedelta, it'll be a number; at some point you have to turn that into
a timedelta object, so you still have the same problem.

Yup, and you do at the boundary instead of having a float wandering through your code with an easily forgotten meta-data type.


So what I'm seeing here is that the direct use of a time_t will cover
everything in an ugly way, but that a class wrapping it up could fix
that. And fundamentally, the only problem with datetime (which, for
the most part, is exactly that wrapper) is that it's unobvious how to
get a simple UTC timestamp.

It has at least one other problem:  bool(midnight) == False.

--
~Ethan~


[1] Yes, I said "puddle of bytes". What would you call it? Am
interested to hear!

I think that's a perfect name!  :)
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to