[Python-ideas] millisecond and microsecond times without floats

Paul Sokolovsky pmiscml at gmail.com
Wed Jun 24 12:13:49 CEST 2015


Hello,

On Wed, 24 Jun 2015 09:19:55 +0200
Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Tue, 23 Jun 2015 23:25:00 +0300
> Paul Sokolovsky <pmiscml at gmail.com> wrote:
> > 
> > Well, that's one of examples of that "desktop" thinking ;-).
> > Consider for example that 2^32 microseconds is just over an hour, so
> > expressing everything in microseconds would require
> > arbitrary-precision integers, which may be just the same kind of
> > burden for an embedded system as floats.
> 
> I'd like to suggest micropython first acquire the ability to handle
> 64-bit numbers (or something close to that, e.g. 60-bit, if it likes
> to use tags for typing), if it wants to become appropriate for precise
> datetime computations.

MicroPython has such support. Long integers can be implemented either
as variable-size arbitrary-precisions integers or and C long long type.
But that doesn't change the fact that 64-bit values still overflow, or
that we don't want to force need for any kind of long integer on any
particular implementation.

We don't even want to mask the fact that fixed-size (time) counters
overflow - for various reasons, including the fact that we want to
follow Python's tradition of being nice teaching/learning language, and
learning embedded programming means learning to deal with timer, etc.
overflows.

So, the question is not how to "appropriate for precise datetime
computations" - MicroPython inherits that ability by being a Python,
but how to scale into the opposite direction, how to integrate into
stdlib "realtime" time handling, which is simple, fast (getting timing
value itself is low-overhead) and modular-arithmetic by its nature.

> 
> That should be less of a heavy requirement than arbitrary-precision
> ints.
> 
> Regards
> 
> Antoine.


-- 
Best regards,
 Paul                          mailto:pmiscml at gmail.com


More information about the Python-ideas mailing list