Zylla Posted December 13, 2017 Posted December 13, 2017 On our devices it is possible to run Python code, but even a simple "Hello World" Python script can take up 6-8 seconds to run, at worst! Investigations seems to show that all Python modules are kept in .py source code, and is compiled in memory on each run. (To save space i guess) Due to having alot of modules and that we're using small embedded devices, this causes delays in even the simplest of Python-related code! Example: Alot of the python scripts on my Mana Toolkit is slow, and causes the CPU-usage to sky-rocket. So what can we do do 'fix' this? Open a SSH terminal to your Pineapple and issue this command: python -m compileall This causes python to pre-compile all your python modules to .pyc-files. Which is located at: /usr/lib/python2.77 This fix is relative straight-forward on the TETRA. On the NANO we're better of moving that directory to the SD-card and issue a sym-link from that directory to: /usr/lib/python2.7 before we run the commmand. (Saves internal storage) For example like this: mv /usr/lib/python2.7 /sd/usr/lib/python2.7 ln -s /sd/usr/lib/python2.7 /usr/lib/python2.7 python -m compileall You can also pre-compile the python files within the directory you're inside by using the same command, but adding a dot at the end, like this: python -m compileall . This was a huge improvement for me. Hope it can be of usage for you guys :)
Just_a_User Posted December 13, 2017 Posted December 13, 2017 57 minutes ago, Zylla said: This was a huge improvement for me. Hope it can be of usage for you guys :) Yep, and so simple. Very nice find! thank you for sharing.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.