Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>writeback=True</code> forces the shelf to keep in-memory any item ever fetched, and write them back when the shelf is closed. So, it consumes much more memory, and slows down closing.</p> <p>The advantage of the parameter is that, with it, you <strong>don't</strong> need the contorted code you show in your comment for mutable items whose mutator is a method -- just</p> <pre><code>shelf['foobar'].append(23) </code></pre> <p>works (if <code>shelf</code> was opened with writeback enabled), assuming the item at key <code>'foobar'</code> is a list of course, while it would silently be a no-operation (leaving the item on disk unchanged) if <code>shelf</code> was opened without writeback -- in the latter case you actually do need to code</p> <pre><code>thelist = shelf['foobar'] thelist.append(23) shekf['foobar'] = thelist </code></pre> <p>in your comment's spirit -- which is stylistically somewhat of a bummer.</p> <p>However, since you <em>are</em> having memory problems, I definitely recommend <strong>not</strong> using this dubious writeback option. I think I can call it "dubious" since I was the one proposing and first implementing it, but that was many years ago, and I've mostly repented of doing it -- it generales more confusion (as your Q evidences) than it allows elegance and handiness in moving code originally written to work with dicts (which would use the first idiom, not the second, and thus need rewriting in order to be usable with shelves without traceback). Ah well, sorry, it <em>did</em> seem a good idea at the time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload