Again, this section will present pseudocode provided in the PEP, though it looks like Python code, to demonstrate how the PEP would work:
- interpreter_isolate.txt demonstrates running code in an isolated manner within an interpreter:
interp = interpreters.create() print('before') interp.run('print("during")') print('after')
- interpreter_spawn_thread.txt shows an interpreter spawning a thread to run Python code:
interp = interpreters.create() def run(): interp.run('print("during")') t = threading.Thread(target=run) print('before') t.start() print('after')
- In interpreter_prepopulate.txt, an interpreter is pre-populated with imported modules, which are initialized; then, the interpreter waits for a call to actually do the ...