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. Cheers, -Barry
signature.asc
Description: PGP signature
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com