Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:27:45+00:00 2026-05-27T13:27:45+00:00

What are the fundamental differences between queues and pipes in Python’s multiprocessing package ?

  • 0

What are the fundamental differences between queues and pipes in Python’s multiprocessing package?

In what scenarios should one choose one over the other? When is it advantageous to use Pipe()? When is it advantageous to use Queue()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:27:45+00:00Added an answer on May 27, 2026 at 1:27 pm

    What are the fundamental differences between queues and pipes in Python’s multiprocessing package?

    Major Edit of this answer (CY2024): concurrency

    As of modern python versions if you don’t need your producers and consumers to communicate, that’s the only real use-case for python multiprocessing.

    If you only need python concurrency, use concurrent.futures.

    This example uses concurrent.futures to make four calls to do_something_slow(), which has a one-second delay. If your machine has at least four cores, running this four-second-aggregate series of function calls only takes one-second.

    By default, concurrent.futures spawns workers corresponding to the number of CPU cores you have.

    import concurrent.futures
    import time
    
    def do_slow_thing(input_str: str) -> str:
        """Return modified input string after a 1-second delay"""
        if isinstance(input_str, str):
            time.sleep(1)
            return "1-SECOND-DELAY " + input_str
        else:
            return "INPUT ERROR"
    
    if __name__=="__main__":
    
        # Define some inputs for process pool
        all_inputs = [
            "do",
            "foo",
            "moo",
            "chew",
        ]
    
        # Spawn a process pool with the default number of workers...
        with concurrent.futures.ProcessPoolExecutor(max_workers=None) as executor:
            # For each string in all_inputs, call do_slow_thing() 
            #    in parallel across the process worker pool
            these_futures = [executor.submit(do_slow_thing, ii) for ii in all_inputs]
            # Wait for all processes to finish
            concurrent.futures.wait(these_futures)
    
        # Get the results from the process pool execution... each
        # future.result() call is the return value from do_slow_thing()
        string_outputs = [future.result() for future in these_futures]
        for tmp in string_outputs:
            print(tmp)
    

    With at least four CPU cores, you’ll see this printed after roughly one-second…

    $ time python stackoverflow.py
    1-SECOND-DELAY do
    1-SECOND-DELAY foo
    1-SECOND-DELAY moo
    1-SECOND-DELAY chew
    
    real    0m1.058s
    user    0m0.060s
    sys     0m0.017s
    $
    

    Original Answer

    At this point, the only major use-case for multiprocessing is to facilitate your producers and consumers talking to each other during execution. Most people don’t need that. However, if you want communication via queue / pipes, you can find my original answer to the OP’s question below (which profiles how fast they are).

    The existing comments on this answer refer to the aforementioned answer below

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are the fundamental differences between Java and C# in terms of inner/local/anonymous classes
Can someone explain to me the fundamental differences between a Cocoa framework and a
What is the fundamental difference between the two? On the server side on the
This is a fundamental question, but an important one none the less... When starting
I've seen posts talk about what might cause differences between Debug and Release builds,
What is the fundamental difference between quicksort and tuned quicksort? What is the improvement
Is there a fundamental difference between how position:fixed; is handled by Firefox 3.0 and
Is there a fundamental difference in terms of performance with regards to using BETWEEN
What is the fundamental difference between the Set<E> and List<E> interfaces?
Scala Where can differences between a class and a type be observed in Scala

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.