In Java, libraries like protostuff
allow you to generate buffers from a Java POJO approximately like so:
Schema<Foo> schema = RuntimeSchema.getSchema(Foo.class);
...
protostuff = ProtostuffIOUtil.toByteArray(foo, schema, buffer);
I've been trying to find a similar solution for Python, but except for attempting to programmatically build Descriptors
and FieldDescriptors
(which come with their own challenges and problems since 4.x.x
), I couldn't find anything. Is this simply impossible in Python, just isn't implemented anywhere, or am I missing something obvious here?