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

[Python-Dev] PEP 410 (Decimal timestamp): the implementation is ready for a review

On Feb 15, 2012, at 10:23 AM, Nick Coghlan wrote:

>What should timedelta.total_seconds() return to avoid losing nanosecond
>precision?  How should this be requested when calling the API?

See, I have no problem having this method return a Decimal for high precision
values.  This preserves the valuable abstraction of timedeltas, but also
provides a useful method for interoperability.

>The core "timestamp" abstraction is "just a number" that (in context)
>represents a certain number of seconds. decimal.Decimal qualifies.
>datetime.timedelta doesn't - it's a higher level construct that makes
>the semantic context explicit (and currently refuses to interoperate
>with other values that are just numbers).

Right, but I think Python should promote the abstraction as the way to
manipulate time-y data.  Interoperability is an important principle to
maintain, but IMO the right way to do that is to improve datetime and
timedelta so that lower-level values can be extracted from, and added to, the
higher-level abstract types.

I think there are quite a few opportunities for improving the interoperability
of datetime and timedelta, but that shouldn't be confused with bypassing them.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120215/53e1333f/attachment.pgp>