Open Flameeyes opened 4 years ago
It appears this is behind a #define
:
STATIC mp_obj_t mod_time_time(void) {
#if MICROPY_PY_BUILTINS_FLOAT
struct timeval tv;
gettimeofday(&tv, NULL);
mp_float_t val = tv.tv_sec + (mp_float_t)tv.tv_usec / 1000000;
return mp_obj_new_float(val);
#else
return mp_obj_new_int((mp_int_t)time(NULL));
#endif
}
STATIC mp_obj_t mod_time_time(void) {
This is only in ports/unix/modtime.c. The erroneous code returning an int
is in
shared-bindings/time/__init__.c
.
We do assume all CircuitPython impls have floats (but not longints).
In CPython 3.8
time.time()
returns a floating point value. In CircuitPython 5.3 on Feather M4 and M0, it returnsint
(or rather a long integer).time.monotonic()
returnsfloat
though.