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

  • Home
  • SEARCH
  • 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 4059208
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:10:43+00:00 2026-05-20T15:10:43+00:00

I have some legacy python code that using pypar and mpich2 to transmit data

  • 0

I have some legacy python code that using pypar and mpich2 to transmit data between multiple nodes. For some reason the data is kept in shelves and pypar wants to pickle the shelve to send it to other nodes. Pickling shelves is not allowed. So I want to convert from shelve to something I can send via pypar which pickles it before sending to other nodes. Any suggestions? Could I convert the shelve to json and pickle that?

  • 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-20T15:10:44+00:00Added an answer on May 20, 2026 at 3:10 pm

    Try converting the shelve to a dict() and then pickling it:

    sdb = shelve.open('foo.db')
    sdb['abc'] = {'a': 1, 'b': 2}
    tmp = cPickle.dumps(dict(sdb), 2)
    print cPickle.loads(tmp)
    {'abc': {'a': 1, 'b': 2}}
    

    Updated: (Response to a question in comments): A dict can copy the key-values from any mapping object, so if that object implements the methods keys and __getitem__ it will work. Since a shelve is a mapping object, the dict copy constructor can read the key-values from the shelve, then you can pickle the resulting dict and ship it to other hosts.

    The example below shows the minimal interface dict requires to copy an object:

    class Foo(object):
    
        def __init__(self):
            self.value = 0
    
        def keys(self):
            return ['a', 'b']
    
        def __getitem__(self, key):
            v = self.value
            self.value += 1
            return self.value
    
    foo = Foo()
    print dict(foo)
    print dict(foo)
    

    Output

    {'a': 1, 'b': 2}
    {'a': 3, 'b': 4}
    

    Update: To add the contents of a dict back to a shelve, use update():

    d = {'a': 1, 'b': 2}
    s = shelve.open('foo.db')
    s.update(d)
    print s
    {'a': 1, 'b': 2}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some legacy code that I'm rewriting using SubSonic to help the future
We have some legacy ASP.NET code that detects if a request is secure, and
I have some legacy code that was used to monitor my applications cpu,memory etc
I have some legacy C++ code that I am trying to understand a bit
I have some data (produced by a legacy application) that I know is invalid
I have some legacy code that contains this typedef: typedef enum simple_op_enum { #define
I have some legacy code that uses Interlocked.Equals to compare values. The values may
Currently I have some legacy ASP.NET 2.0 code that uses the ASP Xml web
I have some legacy Pro*C code using the kind of constructs below. This kind
I have some legacy code that provides a list of the available COM ports

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.