cucumber quick start guide

pip install suitkaise

Serialize and deserialize

from suitkaise import cucumber

# serialize any object to bytes
data = cucumber.serialize(my_object)

# deserialize back
restored = cucumber.deserialize(data)

It works with things pickle can't handle

from 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

Circular references? Handled automatically

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

Live resources become Reconnector objects

Objects like database connections, sockets, and threads can't be directly transferred between processes. cucumber 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.

Debug mode

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)

Inspect the intermediate representation

ir = cucumber.serialize_ir(my_object)
print(ir)  # dict/list structure showing how cucumber sees your object

Convert to JSON

json_str = cucumber.to_json(my_object)

Want to learn more?