我尝试使用 jsonpickle 保存和恢复 collection.deque 列表,但 maxlen 参数在此过程中丢失。
original_test = deque(maxlen=2)
original_test.append(1)
original_test.append(2)
print(original_test)
>>> deque([1, 2], maxlen=2) # everything ok
encoded_test = jsonpickle.encode(original_test)
print(encoded_test)
>>> {"py/seq": [1, 2], "py/object": "collections.deque"} # where is maxlen?
restored_test = jsonpickle.decode(encoded_test)
restored_test.append(3)
print(restored_test)
>>> deque([1, 2, 3]) # maxlen missing