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 999071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:17:39+00:00 2026-05-16T07:17:39+00:00

I have a complex data structure (user-defined type) on which a large number of

  • 0

I have a complex data structure (user-defined type) on which a large number of independent calculations are performed. The data structure is basically immutable. I say basically, because though the interface looks immutable, internally some lazy-evaluation is going on. Some of the lazily calculated attributes are stored in dictionaries (return values of costly functions by input parameter).
I would like to use Pythons multiprocessing module to parallelize these calculations. There are two questions on my mind.

  1. How do I best share the data-structure between processes?
  2. Is there a way to handle the lazy-evaluation problem without using locks (multiple processes write the same value)?

Thanks in advance for any answers, comments or enlightening questions!

  • 1 1 Answer
  • 1 View
  • 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-16T07:17:39+00:00Added an answer on May 16, 2026 at 7:17 am

    How do I best share the data-structure between processes?

    Pipelines.

    origin.py | process1.py | process2.py | process3.py
    

    Break your program up so that each calculation is a separate process of the following form.

    def transform1( piece ):
        Some transformation or calculation.
    

    For testing, you can use it like this.

    def t1( iterable ):
        for piece in iterable:
            more_data = transform1( piece )
            yield NewNamedTuple( piece, more_data )
    

    For reproducing the whole calculation in a single process, you can do this.

    for x in t1( t2( t3( the_whole_structure ) ) ):
        print( x )
    

    You can wrap each transformation with a little bit of file I/O. Pickle works well for this, but other representations (like JSON or YAML) work well, too.

    while True:
        a_piece = pickle.load(sys.stdin)
        more_data = transform1( a_piece )
        pickle.dump( NewNamedTuple( piece, more_data ) )
    

    Each processing step becomes an independent OS-level process. They will run concurrently and will — immediately — consume all OS-level resources.

    Is there a way to handle the lazy-evaluation problem without using locks (multiple processes write the same value)?

    Pipelines.

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

Sidebar

Related Questions

I have a more-or-less complex data structure (list of dictionaries of sets) on which
I have a multithreaded C++ application which holds a complex data structure in memory
I have a directed-graph, each node is a complex data type. Does anyone know
I have a Java program which prepares data into a fairly complex and big
I have a somewhat complex custom user control, created in C# .NET, which is
I have a web service that returns a complex data structure representing the results
I have a ViewModel with a kinda complex data structure. I need my view
I have a templated function fct that uses some complex data structure based on
I have a complex domain structure: User: id, name, email Team: id, name UserTeam:
I have a complex object(tree structure) which I am flattening it out into a

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.