@micropython.native
This causes the MicroPython compiler to emit native CPU instructions rather than the VM bytecode, skipping the interpreter. Most functions require no adaptation.
@micropython.viper
Does a similar thing as the Native code emitter, except it applies some further optimisations that substantially increase performance for integer arithmetic and manipulations.
Viper provides pointer types to assist the optimiser.
ptrPointer to an object.ptr8Points to a byte.ptr16Points to a 16 bit half-word.ptr32Points to a 32 bit machine word.
Also Viper ints are 32-bit machine integers that wrap on overflow, unlike Python’s unlimited integers.
The same python code can drastically give different results in Viper.