shelve keeping old (unused) data around?

AK nospam at nospam.com
Mon Sep 29 22:12:03 CEST 2003


Hello,

I'm using shelve module in python 2.3 and I found that it does a very
odd thing, at least very unexpected to me. It seems that the data of a
replaced or deleted key stays in filename.dat file.

Example:

>>> d = [1]*1000
>>> from shelve import *
>>> s = open('test')
>>> s['test'] = d
>>> s.close()

test.dat is 4100 bytes

>>> d = 1
>>> s = open('test')
>>> s['test'] = d
>>> s.close()

test.dat is still 4100 bytes

If I do del s['test'], it stays the same.





More information about the Python-list mailing list