cucumber quick start guidepip install suitkaise
from suitkaise import cucumber
# serialize any object to bytes
data = cucumber .serialize (my_object)
# deserialize back
restored = cucumber .deserialize (data)
pickle can't handlefrom suitkaise import cucumber
# lambdas
data = cucumber .serialize (lambda x: x * 2)
# closures
def make_multiplier(n):
return lambda x: x * n
data = cucumber .serialize (make_multiplier(3))
# classes defined in __main__ — the reason this matters is pickle
# fails with __main__ classes across processes, cucumber doesn't
class Task:
def __init__(self, n):
self.n = n
def compute(self):
return self.n ** 2
data = cucumber .serialize (Task(7))
restored = cucumber .deserialize (data)
print(restored.compute()) # 49 — class definition survived serialization
from suitkaise import cucumber
class Node:
def __init__(self, name):
self.name = name
self.parent = None
self.children = []
root = Node("root")
child = Node("child")
root.children.append(child)
child.parent = root # circular: child → root → child
data = cucumber .serialize (root)
restored = cucumber .deserialize (data)
print(restored.children[0].parent.name) # "root" — cycle preserved
Reconnector objectsObjects like database connections, sockets, and threads can't be directly transferred between processes. serializes them as Reconnector placeholders, then you reconnect them:
import sqlite3
from suitkaise import cucumber
conn = sqlite3.connect(":memory:")
data = cucumber .serialize (conn)
restored = cucumber .deserialize (data)
# restored is a Reconnector, not a live connection yet
cucumber .reconnect_all (restored)
# now it's a live sqlite3 connection again
For connections that require passwords:
cucumber .reconnect_all (restored, **{
"psycopg2.Connection": {"*": "my_password"}
})
Reconnectors that don't require authentication will lazily reconnect on first access.
When something goes wrong:
# see where serialization failed
cucumber .serialize (obj, debug=True)
# see the full serialization path in real-time
cucumber .serialize (obj, verbose=True)
ir = cucumber .serialize_ir (my_object)
print(ir) # dict/list structure showing how cucumber sees your object
json_str = cucumber .to_json (my_object)
cucumber exists and how it compares to pickle, cloudpickle, and dillcucumber can handle