Movatterモバイル変換


[0]ホーム

URL:


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

Victor Stinnervictor.stinner at gmail.com
Wed Feb 15 14:14:54 CET 2012


2012/2/15 "Martin v. Löwis" <martin at v.loewis.de>:> I agree with Barry here (despite having voiced support for using Decimal> before): datetime.datetime *is* the right data type to represent time> stamps. If it means that it needs to be improved before it can be used> in practice, then so be it - improve it.Decimal and datetime.datetime are not necessary exclusive options.Using the API proposed in the PEP, we can add the Decimal type today,then improve datetime.datetime API, and finally add alsodatetime.datetime type.Such compromise would solve the unspecified starting date issue: anexception would be raised if the timestamp has an unspecifiedtimestamp. In such case, you can still get the timestamp as a Decimalobject with nanosecond resolution. Or we may add support of datetimeand Decimal today, even if datetime only support microsecond, andimprove datetime later to support nanosecond.It looks like there are use cases for Decimal and datetime, both areuseful. At least, datetime has a nice object API related to time,whereas Decimal requires functions from other modules. I don't knowyet if one type is enough to handle all use cases.I wrote a patch to demonstrate that my internal API can be extended(store more information for new types like datetime.datetime) to addnew types later, without touching the public API(func(timestamp=type)). See timestamp_datetime.patch attached to theissue #13882 (the patch is now outside, I can update it if you wouldlike to).For example: - time.time() would support float, Decimal and datetime - os.times() would support float and Decimal (but not datetime)Victor


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp