About Compilation Issues

If you compile well-written MicroPython code into firmware and compare it directly with running MicroPython code, how much difference is there in speed between them? Has anyone compared this?

code that is compiled into the firmware is going to be C code and C code depending on what is being done can be upwards of 200 times faster. It will also consume a lot mess memory too. It depends on what you are doing. MicroPython does have the viper code emitter that allows you to write Python functions that have really close to the same speed as C code. The syntax is not 100% in alignment with Python but it is pretty close. The viper code emitter is really geared around needing to do some heavy number crunching or having to deal with looping code over say a buffer object. It does take a bit of getting used to that’s for sure. There is also the native code emitter, It uses 100% python syntax and you don’t have to declare variables like the viper code emitter. It is faster than typical Python code execution but it does come at a cost, a pretty sizeable increase in memory use.

What exactly are you trying to accomplish?