We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time.time()
In CPython 3.8 time.time() returns a floating point value. In CircuitPython 5.3 on Feather M4 and M0, it returns int (or rather a long integer).
int
time.monotonic() returns float though.
time.monotonic()
float
The text was updated successfully, but these errors were encountered:
It appears this is behind a #define:
#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 }
Sorry, something went wrong.
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.
shared-bindings/time/__init__.c
We do assume all CircuitPython impls have floats (but not longints).
A similar issue recently came up in adafruit/Adafruit_CircuitPython_datetime#29 and adafruit/Adafruit_CircuitPython_datetime#30. It is better to use an int because the precision of the 30-bit floats is so limited. I think we will not fix this for the reasons given in adafruit/Adafruit_CircuitPython_datetime#30.
No branches or pull requests
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.The text was updated successfully, but these errors were encountered: