New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[performance] XBMC plugins are compiled each time they are used #3335
Comments
i investigated 2 years ago this "issue", python ALWAYS compiles py files to pyc or pyo, even if pyo or pyc exist, to avoid this you must remove the py files, this is what we do in our python packages in system to speedup python (at least on rpi this is significant). for addons we dont have control, the user should/must remove py files byself after pyo's are created to benefit here |
I'm seeing the repeated compilation problem with Taking the BBC iPlayer addon as an example, However, a lower level module in this addon, eg. Looking at my installed addons, it seems that hardly any have a compiled If I force the compilation of
so it looks like the Python interpreter on OpenELEC (or maybe it's an XBMC issue? Is this the same on non-OE builds?) is not configured to create and use a pre-compiled |
I tried iplayer with xbmc running on raspbian. I deleted all pyo files first. These are iplayer py files:
This is what I see after using iplayer:
Looks like I see the same thing of default.py not being compiled. |
This would suggest an XBMC rather than OpenELEC issue? |
i think its a general python problem: |
@MilhouseVH I believe python can launch both py files and pyo files. Obviously this is ugly, but if it works then xbmc could be made to try launching default.pyo first, and falling back to python.py. Also how long does it take to compile the largest default.py file? The low-tech solution is to encourage add-on authors to move all code from default.py into a submodule that just gets imported). |
If I rename default.pyo to python.py (and remove default.py) then I get the same error as before when starting the addon: I agree that creating a "minimalist" default.py would seem to be the obvious solution, but can't see that flying amongst addon developers. not least because it doesn't entirely eliminate the problem - you're still wasting time (re-)compiling default.py no matter how trivial it might be. |
it's not a bug. default.py is special. I'll just close this ;) |
XBMC plugins are compiled every time they are executed (no pyo file is created upon execution), while pyo files distributed with plugins are ignored. This means that large plugins on slower/embedded systems have a compilation overhead on directory navigation, in the order of several seconds.
To prove this, create a file with a compile-time warning and notice how the warning is logged every time the plugin is executed. For example:
If this is in your plugin's main file then you'll see a
SyntaxWarning
in xbmc.log every time the plugin is executed. If it'simport
ed by your plugin's main file then it will only be logged the first time the plugin is executed.The text was updated successfully, but these errors were encountered: