On 10/6/20 11:59 AM, Hans-Peter Jansen wrote:
Am Dienstag, 6. Oktober 2020, 20:05:22 CEST schrieb Stefan Brüns:
On Dienstag, 6. Oktober 2020 19:03:39 CEST Hans-Peter Jansen wrote:
[Intentionally disabled line wrapping for the strace snippets]
Hi,
While debugging an ugly segfaulting issue last week, I noticed something strange in the traces when comparing local builds with system builds (the
ones, that were produced from OBS): [...]
After opening the .pyc files, the interpreter always opens the .py files for the system package. For some reason, it doesn't accept the compiled files. The local package behave as expected.
The local files behave *differently*, but none is wrong, see: https://www.python.org/dev/peps/pep-0552/
The distribution pycs have both the 'hash_based' and 'check_source' flags set (5th byte == 0x3), so python has to read the original source to generate and verify the hash.
Needless to say, that this behavior is quite inefficient and not in the sense of the inventor. It would be even more efficient to to do without the compiled version and interpret every python file on load.
Is that to be expected?
Yes.
Hashing the source is quite fast, much faster than generating the bytecode from scratch.
Though, for pycs distributed along the sources, the 'check_source' flag is not strictly needed:
"For hash-based pycs with the check_source unset, Python will simply load the pyc without checking the hash of the source file. The expectation in this case is that some external system (e.g., the local Linux distribution’s package manager) is responsible for keeping pycs up to date, so Python itself doesn’t have to check."
Having the flag set is slightly paranoid, but not wrong per se.
Thanks a lot, Stefan, for explanation and pointers.
One question remains, why don't we trust rpm enough to omit the hash checking for the compiled python modules for our packages?
One advantage of leaving the flag set in my opinion is that if you, as a user or developer, go in and change the "py" file, python re-compiles it for you. If you leave the flag off, then such an update would have to be manually compiled to take effect, and might be a surprise to some.
Cheers, Pete
-- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org