Open William04A opened 1 year ago
Micropython is not CPython, just a small subset. Thus there are many properties which are not implemented. And you seem to have found one. I would not call it a bug. It's by intention not available.
@robert-hh Fair point. Adafruit's CircuitPython has a bug report about this which I linked in the OP which hints that the function is implemented in Micropython, it is just a flag that you enable. It does add some extra code size according to them, but ~100 bytes. Since it is implemented in Micropython, Adafruit considers it a bug and not having the feature presumes that everything you pass to round()
with the n
argument is a float
makes me personally consider this something that should be present in the source code. However, I'm not a MicroPython source code expert of any kind and I know you're much more skilled in that department from our conversations on the PyCom forum :)
Yes, the flag is called MICROPY_PY_BUILTINS_ROUND_INT
, and it is disabled in py/mpconfig.h. If you need it, you have to build the firmware yourself. In MicroPython mainline, it is usually disabled for ports with small flash, and enabled for ports with larger flash. About Pycom: I do not know if there is activity, now that Pycom Inc got bancrupt and some of their business is continued by Pycom BV. Even if the stopped most of their actual products, they will most likely keep MicroPython for their new products. But even then: I could never tell if raising issues in their public repository was noticed. I hardly ever got feedback from Pycom when I did.
P.S.: round(int,int) is kind of a no-op. since it just returns the first int argument.
Hi! I've noticed a bug related to the rounding function.
Board/system information:
Bug report
Rounding integer values with a custom number of decimals seems to throw a
NotImplementedError
:If the values is converted to
float
, it works fine: