2022-09-07, 18:21
Hi experts,
with fresh Raspberry Pi OS Lite and Kodi, Python3-caching is not working properly with the Kodi interpreter. This causes script addons to react very slow on startup, especially on raspberry pi.
In the normal case, python fetches the pre-compiled *.pyc from the /usr/lib/python3.*/../_pycache__ for the python standard libraries. However, Kodi compiles python code with optimization level 1, the pre-compiled file *.opt-1.pyc does not exists by default. As python cannot write into those directories from a user session, it remains like this and Kodi need to compile the libraries every time the script starts. This costs some time.
On powerful desktops, this is not an issue however on the raspberry it is very noticeable.
The two workarounds I found are granting access to the __pycache__ folders in the /usr/lib/python3.* tree or pre-compile all libraries with optimization level 1. But they remain workarounds.
Question: is there a way to start or configure Kodi not to use optimization level 1 when running python code?
with fresh Raspberry Pi OS Lite and Kodi, Python3-caching is not working properly with the Kodi interpreter. This causes script addons to react very slow on startup, especially on raspberry pi.
In the normal case, python fetches the pre-compiled *.pyc from the /usr/lib/python3.*/../_pycache__ for the python standard libraries. However, Kodi compiles python code with optimization level 1, the pre-compiled file *.opt-1.pyc does not exists by default. As python cannot write into those directories from a user session, it remains like this and Kodi need to compile the libraries every time the script starts. This costs some time.
On powerful desktops, this is not an issue however on the raspberry it is very noticeable.
The two workarounds I found are granting access to the __pycache__ folders in the /usr/lib/python3.* tree or pre-compile all libraries with optimization level 1. But they remain workarounds.
Question: is there a way to start or configure Kodi not to use optimization level 1 when running python code?
Code:
sudo find /usr/lib/python3* -name "__pycache__" -exec chmod -R 777 {} \;
or
sudo python -m compileall -o 1 /usr/lib/python3*