Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to store a large python dictionary in a file

I have a python script (script 1) which generate a large python dictionary. This dictionary has to be read by an another script (script 2). Could any one suggest me the best way to write the python dictionary generated by script 1 and to be read by script 2. In past I have used cPickle to write and read such large dictionaries. Is there a beter way to do this?

like image 925
Joel James Avatar asked Dec 19 '25 18:12

Joel James


1 Answers

shelve will give you access to each item separately, instead of requiring you to serialize and deserialize the entire dictionary each time.

like image 149
Ignacio Vazquez-Abrams Avatar answered Dec 21 '25 07:12

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!