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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:38:15+00:00 2026-06-16T05:38:15+00:00

I am working with Shelve in Python and I am having an issue: In

  • 0

I am working with Shelve in Python and I am having an issue:

In [391]: x
Out[391]: {'broken': {'position': 25, 'page': 1, 'letter': 'a'}}

In [392]: x['broken'].update({'page':1,'position':25,'letter':'b'})

In [393]: x
Out[393]: {'broken': {'position': 25, 'page': 1, 'letter': 'a'}}

I don’t understand why its not updating? Any thoughts?

  • 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-06-16T05:38:17+00:00Added an answer on June 16, 2026 at 5:38 am

    This is covered in the documentation. Basically, the keyword parameter writeback to shelve.open is responsible for this:

    If the optional writeback parameter is set to True, all entries
    accessed are also cached in memory, and written back on sync() and
    close(); this can make it handier to mutate mutable entries in the
    persistent dictionary, but, if many entries are accessed, it can
    consume vast amounts of memory for the cache, and it can make the
    close operation very slow since all accessed entries are written back
    (there is no way to determine which accessed entries are mutable, nor
    which ones were actually mutated).

    Example from the same page:

    d = shelve.open(filename) # open -- file may get suffix added by low-level
                              # library
    # as d was opened WITHOUT writeback=True, beware:
    d['xx'] = range(4)  # this works as expected, but...
    d['xx'].append(5)   # *this doesn't!* -- d['xx'] is STILL range(4)!
    
    # having opened d without writeback=True, you need to code carefully:
    temp = d['xx']      # extracts the copy
    temp.append(5)      # mutates the copy
    d['xx'] = temp      # stores the copy right back, to persist it
    
    # or, d=shelve.open(filename,writeback=True) would let you just code
    # d['xx'].append(5) and have it work as expected, BUT it would also
    # consume more memory and make the d.close() operation slower.
    d.close()       # close it
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
Working on a project using Entity Framework (4.3.1.0). I'm trying to figure out how
I am using Python for indexing utilizing the shelve functionality and I was wondering
Working on a little Ruby script that goes out to the web and crawls
Can i shelve some code I've been working on, at work, with TortoiseHG ..
Working on a project, I have this issue where my array slicetable returns undefined
I'm working trying to automatically categorize short articles and I'm trying to figure out
I was hoping someone could help me sort something out. I've been working on
Working on THIS Page: newsite.702wedding.com/live/ Can't find where to remove the arrows at the
Working with DockState and AutoHide, I am looking for the following things: Find out

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.