Message 96538 - Python tracker (original) (raw)
How about using the first patch with the slicing optimization and additionally enhancing GzipFile with the methods required to make it play nice as a raw stream to an io.BufferedReader object (readable(), writable(), readinto(), etc...).
This way we still get the 350% speed up and keep it fully backward compatible, and if someone needs the extra performance they can feed it into an io.BufferedReader object thus:
g = gzip.GzipFile(...) r = io.BufferedReader(g) for line in r: ...