MCPcopy
hub / github.com/marimo-team/marimo / primitive_to_bytes

Function primitive_to_bytes

marimo/_save/encode.py:100–111  ·  view source on GitHub ↗
(value: Any)

Source from the content-addressed store, hash-verified

98
99
100def primitive_to_bytes(value: Any) -> bytes:
101 if value is None:
102 return b":none"
103 if isinstance(value, str):
104 return type_sign(bytes(f"{value}", "utf-8"), "str")
105 if isinstance(value, float):
106 return type_sign(struct.pack("d", value), "float")
107 if isinstance(value, int):
108 return type_sign(struct.pack("q", value), "int")
109 if isinstance(value, tuple):
110 return iterable_sign(map(primitive_to_bytes, value), "tuple")
111 return type_sign(bytes(value), "bytes")
112
113
114def common_container_to_bytes(value: Any) -> bytes:

Callers 2

recurse_containerFunction · 0.85

Calls 3

type_signFunction · 0.85
iterable_signFunction · 0.85
mapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…