[Python-Dev] Store timestamps as decimal.Decimal objects

Antoine Pitrou solipsis at pitrou.net
Tue Jan 31 13:13:30 CET 2012

On Tue, 31 Jan 2012 21:11:37 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:
> Having a low-level module like os needing to know about higher-level
> types like decimal.Decimal and datetime.datetime (or even timedelta)
> should be setting off all kinds of warning bells.

Decimal is ideally low-level (it's a number), it's just that it has a
complicated high-level implementation :)
But we can't use Decimal by default, for the obvious reason
(performance impact that threatens to contaminate other parts of the
code through operator application).

> Of all the
> possibilties that offer decent arithmetic support, timedelta is
> probably the one currently most suited to being pushed down to the os
> level, although decimal.Decimal is also a contender if backed up by
> Stefan's C implementation.

I'm -1 on using timedelta. This is a purity proposition that will make
no sense to the average user. By the way, datetimes are relative too,
by the same reasoning.



More information about the Python-Dev mailing list