I am very new to using micropython and wondered if anyone has installed the mpy_cross package in Thonny and used it to pre-compile .py python files into bytecode .mpy files suitable for running on the pico - done in an effort to speed up the programs.
If so, how do you use this mpy-cross utility within Thonny? There must be some instructions but so far they have evaded me!
Thanks Dave as that explains why I cannot find how to use it! It’s strange that Thonny allows you to install the mpy-cross package from PyPi and then shows it is installed OK, but you cannot use it. I hope that it is added one day.
Is there a way using Windows and external to Thonny to convert a Thonny micropython .py file, eg demo.py, to demo.mpy?
I know it was an old post I originally made but I wondered if there has been any update to Pimoroni providing an mpy-cross (.exe on W11) to work on their uf2 Python code.
I have been using CircuitPython uf2 (9.2.7), which has a mpy-cross (.exe) to create .mpy files from their code (which are faster, etc) and have been most impressed with the improvements.
.
I have tried their mpy-cross.exe on Pimoroni uf2 code and it naturally gives an incompatibility error.
So, my question is has Pimoroni got an mpy-cross.exe to work on their uf2.
I would really be interested in some real figures: what kind of improvements do you see? With precompiled code, you will see some speed improvements, but only once for every module you load (which does a sort of “post-compile”). So I don’t expect really much unless you constantly load additional modules and execute them only once.
I use pre-compiled code for one of my projects, but only because the mpy-files are smaller than the corresponding py-files and I am short on flash-space.
I don’t have timings, only the apparent speed up of graphics loops/redraws, etc, obviously using CircuitPython as mpy-cross is not there for Pimoroni to try. A guesstimate would be 10%. Just try it and see what you think with your test code. Also, because the code is essentially none readable it allows you to liberally comment your project, cross compile (which removes comments as well) and so you can send out prototypes with some form of security to your work and methodology.
I like your comment that the mpy files are smaller which is an advantage to you with you being short on flash space. That is a bonus which I was not looking at.
To recap my query, is there a method to use mpy-cross on Pimoroni uf2 MicroPython code.in the same manner as there is for CircuitPython? I hope so, which would then stop me having to change uf2’s.