Re: [OE-core] python3: Allow to specify which pyc files to keep

Alexander Kanavin
2025-04-10T14:31:31Z

On Thu, 10 Apr 2025 at 15:05, Lukas Woodtli via lists.openembedded.org
<lw=hqv.ch@lists.openembedded.org> wrote:
> The reason to use these features of the Python interpreter is that we develop for
> resource restricted devices. The target device should not need to compile the Python
> files to byte-code at runtime (which happens regardless of the optimization level).
> We can do this work at build time. Moreover, Embedded devices usually
> have restricted storage size. So using the optimization level 2 for pyc files is sensible.
> Most embedded devices don't need the docstrings in the Python files (simmilar to
> not needing the man pages). So we can get rid of them (that is what optimization
> level 2 does, apart from disabling asserts).

Most embedded devices also need to be robust. Lest you forget, python
and its extensions are written in C, and asserts prevent what is
over-generously termed 'undefined behavior', with a loud crash. Which
is a feature some people find useful. Can you demonstrate speedups?

Docstrings argument as well needs to be substantiated with numbers.
How much space is actually being saved?

Is there anything else to these optimizations? Is it documented
anywhere? How can we know if it changes over time, with new python
releases? I feel like this needs to be considered far more carefully
than you have so far.

Alex