Skip to content

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

ericsnowcurrently
Copy link
Member

@ericsnowcurrently ericsnowcurrently commented Jun 30, 2025

@ericsnowcurrently ericsnowcurrently added the needs backport to 3.14 bugs and security fixes label Jun 30, 2025
@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news labels Jun 30, 2025
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Jun 30, 2025
@ericsnowcurrently ericsnowcurrently marked this pull request as ready for review June 30, 2025 23:00
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
Copy link
Contributor

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.

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review docs Documentation in the Doc dir needs backport to 3.14 bugs and security fixes skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants