I recall cStringIO being much faster than io.BytesIO in Python 2.x (orders of magnitude), not sure if it applies to Python 2.7 though.