"shelve" 只是 "dbm" 和 "pickle" 的组合吗?
Is "shelve" just a combination of "dbm" and "pickle"?
所以在 shelve
中完成的所有事情都可以用 dbm
和 pickle
分别完成?
是也不是
是的,它依赖于 dbm
和 pickle
。
The difference with “dbm” databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects — anything that the pickle module can handle
the shelve module is backed by pickle
不,这些模块的使用方式是platform/system-dependent。
The choice of which database package will be used (such as dbm.ndbm or dbm.gnu) depends on which interface is available. Therefore it is not safe to open the database directly using dbm. The database is also (unfortunately) subject to the limitations of dbm, if it is used — this means that (the pickled representation of) the objects stored in the database should be fairly small, and in rare cases key collisions may cause the database to refuse updates.
更多内容在 official documentation。
所以在 shelve
中完成的所有事情都可以用 dbm
和 pickle
分别完成?
是也不是
是的,它依赖于 dbm
和 pickle
。
The difference with “dbm” databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects — anything that the pickle module can handle
the shelve module is backed by pickle
不,这些模块的使用方式是platform/system-dependent。
The choice of which database package will be used (such as dbm.ndbm or dbm.gnu) depends on which interface is available. Therefore it is not safe to open the database directly using dbm. The database is also (unfortunately) subject to the limitations of dbm, if it is used — this means that (the pickled representation of) the objects stored in the database should be fairly small, and in rare cases key collisions may cause the database to refuse updates.
更多内容在 official documentation。