Movatterモバイル変換


[0]ホーム

URL:


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

Barry Warsawbarry at python.org
Wed Feb 15 14:36:06 CET 2012


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 precisionvalues.  This preserves the valuable abstraction of timedeltas, but alsoprovides 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 tomanipulate time-y data.  Interoperability is an important principle tomaintain, but IMO the right way to do that is to improve datetime andtimedelta so that lower-level values can be extracted from, and added to, thehigher-level abstract types.I think there are quite a few opportunities for improving the interoperabilityof datetime and timedelta, but that shouldn't be confused with bypassing them.Cheers,-Barry-------------- next part --------------A non-text attachment was scrubbed...Name: signature.ascType: application/pgp-signatureSize: 836 bytesDesc: not availableURL: <http://mail.python.org/pipermail/python-dev/attachments/20120215/53e1333f/attachment.pgp>


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp