rocksdict/RocksDict

TypeError: cannot pickle 'generator' object

Euraxluo opened this issue · 5 comments

code:

from rocksdict import Rdict

path = str("./test_dict")
db = Rdict(path)
def f(a, b):
    for n in range(a):
        yield b + b[-1] * n


gen = f(4, 'ay')
x = next(gen)
db['gx'] = gen

error:

TypeError: cannot pickle 'generator' object

thinking:

It should be the cause of pickling, but it doesn't fit the readme description of being able to store anything

Default mode, which allows storing int, float, bool, str, bytes, and other python objects.

Right, only python objects that can be pickled. But you might also use raw_mode to store objects in custom encoding.

in history commit :value: int, float, bool, str, bytes and anything that supports pickle.

i will try,thx

Updated the readme, adding (with Pickle) to clarify this problem.