Skip to content

schema_adapter

πŸ€– AI-Generated Content

This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.

pyvider.conversion.schema_adapter

Classes

Functions

pvs_schema_to_proto async

pvs_schema_to_proto(schema: PvsSchema) -> pb.Schema

Converts a PvsSchema into a protobuf Schema message.

Caches by object identity since PvsSchema is frozen (immutable). Stores a reference to the source object to prevent id reuse after GC.

Source code in pyvider/conversion/schema_adapter.py
async def pvs_schema_to_proto(schema: PvsSchema) -> pb.Schema:
    """Converts a PvsSchema into a protobuf Schema message.

    Caches by object identity since PvsSchema is frozen (immutable).
    Stores a reference to the source object to prevent id reuse after GC.
    """
    schema_id = id(schema)
    entry = _proto_schema_cache.get(schema_id)
    if entry is not None and entry[0] is schema:
        return entry[1]
    proto_block = _pvs_object_type_to_proto(schema.block)
    result = pb.Schema(version=schema.version, block=proto_block)
    _proto_schema_cache[schema_id] = (schema, result)
    return result