[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-12 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset d2a8e69c2c605fbaa3656a5f99aa8d295f74c80e by Inada Naoki in branch 
'master':
bpo-43787: Add __iter__ to GzipFile, BZ2File, and LZMAFile (GH-25353)
https://github.com/python/cpython/commit/d2a8e69c2c605fbaa3656a5f99aa8d295f74c80e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-12 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-12 Thread Ma Lin


Ma Lin  added the comment:

I think this change is safe.

The behaviors should be exactly the same, except the iterators are different 
objects (obj vs obj._buffer).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-12 Thread Ma Lin


Change by Ma Lin :


--
nosy: +malin

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-12 Thread Inada Naoki


Change by Inada Naoki :


--
keywords: +patch
pull_requests: +24088
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/25353

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-11 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
stage:  -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-11 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-09 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43787] Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.

2021-04-09 Thread Inada Naoki


New submission from Inada Naoki :

__iter__ method of BZ2File, GzipFile, and LZMAFile is IOBase.__iter__. It calls 
`readline()` for each line.

Since `readline()` is defined as Python function, it is slower than C iterator. 
Adding custom __iter__ method that delegates to underlying buffer __iter__ 
makes `for line in file` 2x faster.

def __iter__(self):
self._check_can_read()
return self._buffer.__iter__()

---

The original issue is reported here.
https://discuss.python.org/t/non-optimal-bz2-reading-speed/6869
This issue is relating to #43785.

--
components: Library (Lib)
messages: 390599
nosy: methane
priority: normal
severity: normal
status: open
title: Optimize BZ2File, GzipFile, and LZMAFile __iter__ method.
type: performance
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com