Why is it that *dbm modules don't provide an iterator? (Language design question)

skip at pobox.com skip at pobox.com
Thu Apr 9 17:53:42 EDT 2009


    Joshua> Why not

    Joshua> for key in d.keys():
    Joshua>     print key

    Joshua> That worked for me.

Time & space.  One motivation for using dbm files is to write large (huge,
in fact) mappings to disk.  Simply reconstituting the entire set of keys may
consume a lot of time (they must all be enumerated before you begin working
with any of them) and space (the number of keys in the file might be very
large).

-- 
Skip Montanaro - skip at pobox.com - http://www.smontanaro.net/
        "XML sucks, dictionaries rock" - Dave Beazley



More information about the Python-list mailing list