-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-134939: Add a Multiple Interpreters Howto Doc #136143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
gh-134939: Add a Multiple Interpreters Howto Doc #136143
Conversation
are still relatively inefficient and limited | ||
* actually *sharing* data safely is tricky (true for free-threading too) | ||
* all necessary modules must be imported separately in each interpreter | ||
* relatively slow startup time per interpreter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some users might need a (foot)note that subinterpreters can sometimes improve the startup by importing nothing.
example
def non_stateless():
non_stateless
if __name__ == '__main__':
import threading
from concurrent import interpreters
interps = [interpreters.create() for i in range(10)]
threads = [
threading.Thread(target=interp.call, args=(non_stateless,))
for interp in interps
]
for thread in threads:
thread.start()
for thread in threads:
thread.join()
That seems not so beneficial for the InterpreterPoolExecutor
case, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a note, though further down in the discussion about calling functions.
📚 Documentation preview 📚: https://cpython-previews--136143.org.readthedocs.build/