New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
io-c: TextIOWrapper is faster than BufferedReader but not protected by a lock #49752
Comments
TextIOWrapper.readline() is much faster (eg. 72 ms vs 95 ms) than I would like a BufferedReader.readline() as fast as Why BufferedReader's attributes are protected by a lock whereas Does it mean that TextIOWrapper may crash if two threads calls How does Python 2.x and 3.0 fix this issue? |
I wrote a short script to test TextIOWrapper.readline() with 32 Exception in thread Thread-26:
Traceback (most recent call last):
File "/home/SHARE/SVN/python-trunk/Lib/threading.py", line 522, in
__bootstrap_inner
self.run()
File "/home/haypo/crash_textiowrapper.py", line 15, in run
line = self.file.readline()
File "/home/SHARE/SVN/python-trunk/Lib/io.py", line 1835, in
readline
self._rewind_decoded_chars(len(line) - endpos)
File "/home/SHARE/SVN/python-trunk/Lib/io.py", line 1541, in
_rewind_decoded_chars
raise AssertionError("rewind decoded_chars out of bounds")
AssertionError: rewind decoded_chars out of bounds But it looks that py3k is stronger because it doesn't crash. Is it the |
Yes, it is. |
Here is a patch which provides a significant speedup (up to 30%) on |
Committed in r71483. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: