-
I'm working on a project with approximately 30 Python scripts. Some of these scripts are used only once, imported via
Which approach is generally considered best practice to save ROM space or improve performance ? As is, the app boots in :
Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
My question would be, what is more important for you. Boot-up time or execution speed. There might be a difference in execution speed. Frozen bytecode stays in flash memory. Since the flash is serially attached, the code is download block-by-block to RAM during execution. To speed up that process, there is a cache. There will be cache misses during execution, causing short delays. If you import script from the regular file system, the code will be placed in RAM, maybe after compilation. Unless it is PSRAM, the access to internal RAM is faster than Flash access. In particular there should not be delays due to cache misses. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the answer and for your time ! |
Beta Was this translation helpful? Give feedback.
My question would be, what is more important for you. Boot-up time or execution speed.
As you found out yourself, loading code from frozen bytecode is fast. It should not matter much, whether it's few large files for many smaller ones, since the code is not loaded to RAM. With mayn small files, a little more time is spent for directory searches. The only was I see to speed up boot time is lazy importing: import a script not before you need it.
There might be a difference in execution speed. Frozen bytecode stays in flash memory. Since the flash is serially attached, the code is download block-by-block to RAM during execution. To speed up that process, there is a cache. There will be cache…