Python code minification tool #15451
Replies: 8 comments 5 replies
-
What stops our from using your preferred minification tool and integrate it in your workflow for uploading files? |
Beta Was this translation helpful? Give feedback.
-
The simplest approach is to cross-compile: see mpy-cross. |
Beta Was this translation helpful? Give feedback.
-
Minify is used in JS world. Pythoneers don't do this. You can compile Python code and you can compile Micropython code. The use of MPY is the right approach. |
Beta Was this translation helpful? Give feedback.
-
Oh wow, nice, thanks for the answers :) so I thought it is a thing. |
Beta Was this translation helpful? Give feedback.
-
I thought Or is it the same as: |
Beta Was this translation helpful? Give feedback.
-
Here's another one : I tried a minifier a while back and it worked great. Cut the source by 2/3. Probably would have done better if I used comments. 😀 Curt |
Beta Was this translation helpful? Give feedback.
-
I use pyminify from https://pypi.org/project/python-minifier/ You can install it with
The documentation can be found at https://dflook.github.io/python-minifier/ It is not inconceivable that you might want to obfuscate your code and reduce code size by reusing variable names. There are many reasons why you might want to do this. I use pyminify and then mpy-cross on finished scripts. |
Beta Was this translation helpful? Give feedback.
-
VIperIDE is able to minify (and prettify) the source file.
Please note that these operations are destructive (however you can undo them in the editor view) |
Beta Was this translation helpful? Give feedback.
-
It would be great to have some tool to minify python code before sending it to the board.
It would save some space and we could have lots of comments in out source files during development.
Removing comments and white spaces would really be enough for the start.
Beta Was this translation helpful? Give feedback.
All reactions