Skip to content

parseDelimitedFrom and writeDelimitedTo only available in Java. #27

Description

@cmacdonald

We use message.writeDelimitedTo() in Java to write multiple messages into a stream. However, this function is only available in Java. See also https://www.datadoghq.com/blog/engineering/protobuf-parsing-in-python/

My replacement in Python:

def write_delimited(f, o):
  from google.protobuf.internal.encoder import _VarintBytes
  from google.protobuf.internal.decoder import _DecodeVarint32
  size = o.ByteSize()
  f.write(_VarintBytes(size))
  f.write(o.SerializeToString())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions