This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Increase TextIOWrapper._CHUNK_SIZE
Type: performance Stage:
Components: Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, pitrou
Priority: high Keywords:

Created on 2008-12-14 18:18 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg77814 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-12-14 18:18
Simply bumping TextIOWrapper._CHUNK_SIZE from 128 to 1024 yields some
significant performance improvements.

./python -m timeit -s "f=open('LICENSE')" "f.seek(0)" "for line in f: pass"
 -> with 128: 6.21 msec per loop
 -> with 1024: 3.41 msec per loop

./python -m timeit -s "f=open('LICENSE')" "f.seek(0)" "while
f.read(100): pass"
 -> with 128: 4.03 msec per loop
 -> with 1024: 1.25 msec per loop

Is there any counter-indication to doing so?
msg77890 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-12-15 23:04
Committed in r67803, r67804.
History
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48913
2008-12-15 23:04:19pitrousetstatus: open -> closed
resolution: fixed
messages: + msg77890
2008-12-14 18:18:30pitroucreate