← index #11667Issue #11551
Off-topic · high · value 1.799
QUERY · ISSUE

ViperTypeError: div/mod not implemented for uint

openby massimosalaopened 2023-05-30updated 2024-09-04
enhancement

General topic, not related to a specific micro.

Viper is great for optimizing functions, like custom hashes, that only do calculations on integers... but

ViperTypeError: div/mod not implemented for uint

Is it possible to implement this?

CANDIDATE · ISSUE

docs: micropython.viper: number of arguments in functions

closedby massimosalaopened 2023-05-18updated 2023-05-18

From the official doc https://docs.micropython.org/en/v1.9.3/pyboard/reference/speed_python.html#the-viper-code-emitter

In addition to the restrictions imposed by the native emitter the following constraints apply:

  • Functions may have up to four arguments

Well, I am using a function with 7 arguments... and it works.

I tested the crc calculation with 19 different polynomials, input data "123456789" and the expected results published here
https://crccalc.com/

@micropython.viper
def crc_msb(shift: uint, data: ptr8, ldata: int, init: uint, poly: uint, xor_in: uint = 0, xor_out: uint = 0) -> uint :
...

Mmh to be sure, how do you suggest to check if the function is running optimized or not?
(preferably a method not depending on execution times).

Is it the documentation up-to-date?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied