Message245107
| Author |
martin.panter |
| Recipients |
Arfrever, Michael.Fox, eric.araujo, larry, martin.panter, nadeem.vawda, pitrou, rhettinger, serhiy.storchaka, vstinner |
| Date |
2015年06月10日.03:07:24 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1433905645.22.0.923846653636.issue18003@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|