Real file objects slower than StringIO and cStringIO?
StringIO has the following notes in its code: Notes: - Using a real file is often faster (but less convenient). - There's also a much faster implementation in C, called cStringIO, but it's not subclassable. The "real file is often faster" line seemed really odd to me: how could writing to disk beat writing to memory? I tried profiling these different cases and got results that contradict these docs, as well as the answer to this question . This other question does explain why cStringIO is slower under some circumstances, though I'm not doing any concatenating here. The test writes a given