Wednesday 15 July 2015

python - how to use custom encoding/decoding with Google Protobuf -



python - how to use custom encoding/decoding with Google Protobuf -

i'm writing python app has protobuf messages defined. however, need utilize custom wire format (i believe that's right term).

how (in python) override base of operations encoding functions?

i've looked in encoder.py , that's maze of nested functors. need monkey patch (or whatever) specify own encodings?

thanks.

i wouldn't recommend trying monkey-patch encoding functions. break something.

what can write independent function encodes protobuf in arbitrary way via reflection. illustration of this, see text_format.py module in protobufs itself. module encodes , decodes messages in alternative human-readable format exclusively based on public descriptor , reflection interfaces. can follow same pattern write own encoder/decoder format.

python protocol-buffers

No comments:

Post a Comment