Re: Python - Appending repeated messages instead of merging

2009-06-15 Thread Kenton Varda
This is tricky as the Python API (like the C++ API) has a strong sense of ownership. Outer messages "own" the message objects embedded inside them. In the Python API, this is necessary because assigning a field in an optional sub-message may also cause the sub-message itself to become present in

Python - Appending repeated messages instead of merging

2009-06-11 Thread Dan
Hello, I'm finding that I am writing code that looks a lot like this: tmpsubmessage = parse_submessage_data() submessage = message.submessage.add() submessage.MergeFrom(tmpsubmessage) This seems inefficient to me. One alternative would be to create the new submessage, and fill it on the spot: