datastax/python-driver — pull request #143 by ccstolley (2014-06-14 18:16:58+00:00)
Title: Replace six.BytesIO with io.BytesIO for speed-up

On python 2.6 and 2.7, six.BytesIO maps to StringIO, which is slow:

https://github.com/kelp404/six/blob/master/six.py#L478

Python 2.6 and 2.7 provide the io module (for compatability with
the Python 3 io module), which defines a faster BytesIO implementation.
cProfile reveals a significant speedup when using the io module. Using
six.BytesIO:

ncalls tottime percall cumtime percall filename:lineno(function)
...
2277792 9.736 0.000 13.088 0.000 /usr/lib64/python2.6/StringIO.py:208(write)

However with io.BytesIO:

2277792 0.920 0.000 0.920 0.000 {method 'write' of '_bytesio._BytesIO' objects}

This will break on Python 2.5, but I think that's ok.