A bytecode for (LLDB) data formatters

It seems like in terms of usability and user experiences saving a vanilla Python script would be the most convenient and straight forward approach vs introducing a new approach and providing a whole infra for creating bytecodes and implementing a dedicated interpreter.

but Python code is larger and more importantly it is potentially dangerous to just load an execute untrusted Python code in LLDB.

If your main concern is about executing untrusted Python code, have you considered sandboxing Python script execution by providing custom global/local environment dictionaries to something like Python’s eval/exec and thus fully controlling/restricting the API surface of what such a Python script can access and do?