If you want to save memory when reading from a BytesIO, getvalue() is surprisingly a good choice.

» Itamar Turner-Trauring | pythonspeed.com