Martin Panter added the comment:

The BufferedReader class is documented as being thread safe: 
<https://docs.python.org/dev/library/io.html#multi-threading>. Some 
experimentation suggests that checking the “raw.closed” property is not 
actually serialized, but that raw.readinto() calls are serialized. I don’t 
think this is a big problem in practice, so I think BZ2File would remain as 
thread-safe as BufferedReader is.

But Serhiy’s point is definitely valid about the classes breaking the iterator 
protocol. FWIW I originally made this patch to satisfy my personal curiosity 
about why wrapping a second BufferedReader made things so much faster. Now I 
accept it is partly due to the overhead of the extra LZMAFile.readline() to 
BufferedReader.readline() delegation. Maybe it is not even worth optimizing 
around this kind of overhead, so I would even be happy to drop this patch and 
close the issue.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18003>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to