@micropython.native or mpy #9225
-
For a class I have I can decorate it with @micropython.native or I can cross-compile it to a mpy file (without the decorator). I think I could also create an mpy file that also has the decorator but then I have to put --march=armv6m (which I think is correct for the rpi pico) but then I get But nevertheless, leaving to one side for the moment the mpy with decorator scenario, I can easily decorate my class or create an mpy. Both appear to work OK. Is there any guidance as to which might be the better choice? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
If you ask about runtime speed, there is not difference between a .py and a .mpy version. It is just a when and where the converting from .py to .mpy happens. Standard code and @micropython.native code have a difference in code execution speed. As a rule of thumb, @micropython.native code runs twice as fast. |
Beta Was this translation helpful? Give feedback.
-
You don't need to specify the heap size when using mpy-cross. Only the architecture (and even then only if your code uses If you use emit=native with mpy-cross then it's like implicitly putting As Robert said there's no runtime speed difference between bytecode generated on the device vs via mpy-cross in a .mpy file. (They use exactly the same code... mpy-cross is actually just micropython running on your PC in a special mode that can serialise the generated bytecode). The reason to use a .mpy file is that:
|
Beta Was this translation helpful? Give feedback.
If you ask about runtime speed, there is not difference between a .py and a .mpy version. It is just a when and where the converting from .py to .mpy happens. Standard code and @micropython.native code have a difference in code execution speed. As a rule of thumb, @micropython.native code runs twice as fast.
So it is not a question of .mpy or @micropython.native code