[Python-Dev] Store timestamps as decimal.Decimal objects
Antoine Pitrou
solipsis at pitrou.net
Wed Feb 1 03:35:14 CET 2012
On Wed, 1 Feb 2012 10:35:08 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> With this approach, API usage might end up looking something like:
>
> >>> time.time()
> 1328006975.681211
> >>> time.time(convert=time.as_float)
> 1328006975.681211
> >>> time.time(convert=time.as_int)
> 1328006979
> >>> time.time(convert=time.as_tuple)
> (1328006975, 681211, -9)
> >>> time.time(convert=decimal.Decimal.from_components)
> Decimal('1328006983.761119000')
It strikes me as inelegant to have to do so much typing for something
as simple as getting the current time. We should approach the
simplicity of ``time.time(format='decimal')`` or
``time.decimal_time()``.
(and I think the callback thing is overkill)
Regards
Antoine.
More information about the Python-Dev
mailing list