shelve

Pickle versus shelve storing large dictionaries in Python

落爺英雄遲暮 提交于 2019-11-27 01:49:55
问题 If I am storing a large directory as a pickle file, does loading it via cPickle mean that it will all be consumed into memory at once? If so, is there a cross platform way to get something like pickle , but access each entry one key at a item (i.e. avoid loading all of the dictionary into memory and only load each entry by name)? I know shelve is supposed to do this: is that as portable as pickle though? 回答1: I know shelve is supposed to do this: is that as portable as pickle though? Yes.