[issue5736] Add the iterator protocol to dbm modules
Christopher Lee
report at bugs.python.org
Thu Aug 6 02:32:38 CEST 2009
Christopher Lee <leec at chem.ucla.edu> added the comment:
Another reason this issue is really important, is that the lack of a
consistent iter() interface for dbm.* makes shelve iteration not
scalable; i.e. trying to iterate on a Shelf will run self.dict.keys() to
load the entire index into memory. This seems contrary to a primary
purpose of shelve, namely to store the index on-disk so as to avoid
having to keep the whole index in memory.
I suspect that for most users, shelve is the main way they will access
the dbm.* interfaces. Therefore, fixing the dbm.* interfaces so that
shelve is scalable seems like an important need.
Once dbm and gdbm support the iterator protocol, it will be trivial to
add an __iter__() method to shelve.Shelf, that simply returns
iter(self.dict).
----------
nosy: +foobaron
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5736>
_______________________________________
More information about the Python-bugs-list
mailing list