bumptech/palm — pull request #28 by dowski (2013-04-04 21:39:48+00:00)
Title: Efficient Repeated Appends

If all you are doing is loading a protobuf, appending a new field, and
saving again, this feature can really save memory use. It doesn't render
all the repeated submessages to python objects. It just modifies the
internal structures.

Here's the output of `check_mem.py` for a base interpreter load, a normal
append and a fast append (memory use in KB):

baseline 32748 6876
normal-append 633364 607288
fast-append 59092 33344

Due to the way that repeated fields are implemented, I couldn't hook into the `RepeatedSequence` field itself without being too invasive (I think that would need to happen in a PALM 2.x release). Instead there is a new method generated for repeated fields, `Proto.__fast_apend(value)`. Not the prettiest API but for simple stuff the standard API works well. This is for when you need to reach down and pull out extra performance when dealing with many values in repeated fields.