How to do it...

Again, this section will present pseudocode provided in the PEP, though it looks like Python code, to demonstrate how the PEP would work:

  1. interpreter_isolate.txt demonstrates running code in an isolated manner within an interpreter:
        interp = interpreters.create()        print('before')        interp.run('print("during")')        print('after')
  1. 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')
  1. 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 ...

Get Secret Recipes of the Python Ninja now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.