You can wrap the string in StringIO or BytesIO and pretend to be a file. It should be pretty fast.
from cStringIO import StringIO # or, in Py3/Py2.6+: #from io import BytesIO, StringIO s = StringIO(large_string) while True: chunk = s.read(200) if len(chunk) > 0: process(chunk) if len(chunk) < 200: break
Fred foo
source share