Python without __pychache__ folder performance

I have docker container with some python 3.8 application, and volume with python source code mounted read-only for security reasons. So, __pychache__ folders cannot be created (and not exists after deploy). How does python feel in this configuration? Is performance degraded or not? May be it’s better to set PYTHONPYCACHEPREFIX? Or it is doesn’t matter?

It will depend on your Python application, but generally, the __pycache__ folder will speed up imports.

If your application is a single module file, then it won’t get cached and the lack of the __pycache__ folder won’t matter. But if there are many .py files which get imported by the main application script, they will normally get cached, and the next time you run the application, the imports will be faster.

You can pre-cache the .py files using the compileall script.

Thank you, really useful answer