shelve file space always increase!

Michael Palmer m_palmer45 at yahoo.ca
Wed Sep 17 08:14:04 EDT 2008


On Sep 17, 6:17 am, smalltalk <ttkk1... at gmail.com> wrote:
> >>> import shelve
> >>> sf = shelve.open('e:/abc.db')
> >>> for i in range(10000):
>
> ...     sf[str(i)]=i
> ...>>> sf.close()
> >>> sf = shelve.open('e:/abc.db')
> >>> sf.clear()
> >>> sf
>
> {}
> the abc.db is always 312k though i have use clear(), how can i shrink
> the space?

shelve doesn't have any way of doing that. the only option is to read
all items from your shelve and write them to a new one.



More information about the Python-list mailing list