Embed python to execute with PYTHONHOME for prior Python version

What if I build an application (GDB for example) statically linked with the latest Python (e.g.: libpython3.11.so) and run it on different environments that have installed the latest Python or above (e.g. 3.6)? (Of course, PYTHONHOME and PYTHONPATH are set to Python 3.6 before execution)

I already read that Python has backward compatibility and all scripts that worked with prior versions still work with the newest Python.

But may that approach be harmful to the Python installation that will be used in PYTHONHOME? Maybe the newest Python (3.11) may generate a bytecode that ruins execution via “donor” Python(3.6)? I’m not experienced in Python internals much…

Why not use the gdb that comes with your distro? And the pyhthon it was built to use?

@barry-scott , I should create distributions to make every user happy that uses Python from 3.6 to the latest :exploding_head: (Release esp-gdb-v12.1_20221002 · espressif/binutils-gdb · GitHub)

Cool goal for lots of uses of python.

But given that, I recall, gdb and python is a tight binding together its not obvious too me it will be easy or worth doing.