How can I speed up unpickling large objects if I have plenty of RAM?

前端 未结 8 913
别那么骄傲
别那么骄傲 2020-12-09 09:07

It\'s taking me up to an hour to read a 1-gigabyte NetworkX graph data structure using cPickle (its 1-GB when stored on disk as a binary pickle file).

Note that the

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 09:30

    You're probably bound by Python object creation/allocation overhead, not the unpickling itself. If so, there is little you can do to speed this up, except not creating all the objects. Do you need the entire structure at once? If not, you could use lazy population of the data structure (for example: represent parts of the structure by pickled strings, then unpickle them only when they are accessed).

提交回复
热议问题