Utime vs time and ubinascii vs binascii

Apologies if this is a silly question.

Ive spent a good amount of time looking at code examples for the Pycom boards. Many examples seem to import and use time or utime and similarly ubinascii or binascii to achieve the same results.

Question: Whats the difference between importing time or utime and binascii or ubinascii?

Thx
Jon

These have the same functionality, but the time module is system maintained, and does not require a hardware RTC. The system determines the time at boot, either from a RTC if present, or some other means. This may result in time being set to the epoch, 1970/01/01 O0:00:00.

utime relies on a hardware RTC and should be used if there is no OS to maintain a clock.

ubinascii is a subset of binascii. Check the functions in each module to see which meets your needs

Thanks, this is useful. I have used time before on RPi’s but now Im using LoPy4’s I’ll start using utime.

As far as binascii is concerned, so far Im only needing it for LoRaWAN OTAA, so ubinascii does the trick.

Thx
Jon

Hi Jon,

When available I have found that the “micro” version of available libraries are better to use for hardware applications. The original libraries may not have been designed for hardware like a Lopy4, but the microPython version certainly has. They have a lot of overlap, and rarely require significant changes.

1 Like