[Python-ideas] millisecond and microsecond times without floats

Paul Sokolovsky pmiscml at gmail.com
Wed Jun 24 12:59:08 CEST 2015


Hello,

On Wed, 24 Jun 2015 12:40:10 +0200
Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Wed, 24 Jun 2015 13:13:49 +0300
> Paul Sokolovsky <pmiscml at gmail.com> wrote:
> > 
> > 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.
> 
> I'm sorry, I don't understand. If you have 64-bit ints then why would
> you use anything smaller for timestamps?

Because MicroPython stays close (== may stay close) to hardware and does
not depend on any OS (even those smaller embedded OSes, which are
called RTOS'es). Then, it's usual case for embedded hardware to have
hardware timers of the same size or smaller as the architecture machine
word. For example, on a 32-bit CPU, timers are usually 32-, 24-, or 16-
bit. On 16-bit CPUs, timers are 16- or 8-bit. Put it otherwise way,
there's simply nowhere to get 64-bit time value from, except by building
software abstractions, and MicroPython does not *require* them (if they
exist - good, they will be helpful for other things, if not -
MicroPython can still run and do a large subset of useful things).

Another reason is that MicroPython exactly uses tagged pointers
scheme, and small integers are value, not reference, objects. Dealing
with them is largely faster (MicroPython easily beats CPython on
(small) integer performance), and doesn't require memory allocation
(the latter is another important feature for embedded systems).

> 
> Regards
> 
> Antoine.


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


More information about the Python-ideas mailing list