Python Disk-Based Dictionary

后端 未结 8 1692
逝去的感伤
逝去的感伤 2020-12-04 16:44

I was running some dynamic programming code (trying to brute-force disprove the Collatz conjecture =P) and I was using a dict to store the lengths of the chains I had alread

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

    The 3rd party shove module is also worth taking a look at. It's very similar to shelve in that it is a simple dict-like object, however it can store to various backends (such as file, SVN, and S3), provides optional compression, and is even threadsafe. It's a very handy module

    from shove import Shove
    
    mem_store = Shove()
    file_store = Shove('file://mystore')
    
    file_store['key'] = value
    

提交回复
热议问题