[Python-ideas] millisecond and microsecond times without floats

Nick Coghlan ncoghlan at gmail.com
Fri Jun 26 10:00:44 CEST 2015


On 26 June 2015 at 04:06,  <random832 at fastmail.us> wrote:
> On Mon, Jun 22, 2015, at 19:15, Paul Sokolovsky wrote:
>>
>>
>> Hello from MicroPython, a lean Python implementation
>> scaling down to run even on microcontrollers
>> (https://github.com/micropython/micropython).
>>
>> Our target hardware base oftentimes lacks floating point support, and
>> using software emulation is expensive. So, we would like to have
>> versions of some timing functions, taking/returning millisecond and/or
>> microsecond values as integers.
>
> What about having a fixed-point decimal numeric type to be used for this
> purpose?
>
> Allowing time (and stat, and the relevant functions of the datetime
> module) to return any real numeric type rather than being required to
> use float would be a useful extension.

It isn't the data type that's the problem per se, it's the additional
abstraction layers - the time module assumes it's dealing with
operating system provided timing functionality, rather than accessing
timer hardware directly. Folks tend to think that the os and time
modules are low level, but there's a wonderful saying that asks "How
do you tell the difference between a software developer and a computer
systems engineer?" Answer:

Software developer: "In a *low* level language like C..."
Computer systems engineer: "In a *high* level language like C..."

Paul, what do you think of the idea of trying to come up with a
"hwclock" module for MicroPython that aims to expose very, very low
level timing functionality as you describe, and reserving that name
for independent distribution on PyPI? Such a module could even
eventually grow a plugin system to provide access to various real time
clock modules in addition to the basic counter based clocks you're
interested in right now.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list