I wonder if we should pull in https://github.com/alex/pyfast_buffer for this, this pattern is pretty inefficient /cc @dreid