def parse_stream(stream: with_attr("read", "tell")) -> odict: return bs_to_py(BSON_Document.parse(stream))
def serialize_to_stream(document: dict, stream: with_attr("write", "flush")): py_to_bs(document).serialize(stream) stream.flush()