Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cpython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
Python
cpython
Commits
d815cc066df8
Commit
d815cc066df8
authored
4 years ago
by
Inada Naoki
Browse files
Options
Downloads
Patches
Plain Diff
bpo-43787: Add __iter__ to GzipFile, BZ2File, and LZMAFile (GH-25353)
parent
e72ec941c76f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Lib/bz2.py
+4
-0
4 additions, 0 deletions
Lib/bz2.py
Lib/gzip.py
+4
-0
4 additions, 0 deletions
Lib/gzip.py
Lib/lzma.py
+4
-0
4 additions, 0 deletions
Lib/lzma.py
Misc/NEWS.d/next/Library/2021-04-12-15-15-50.bpo-43787.wCy_Wd.rst
+3
-0
3 additions, 0 deletions
...S.d/next/Library/2021-04-12-15-15-50.bpo-43787.wCy_Wd.rst
with
15 additions
and
0 deletions
Lib/bz2.py
+
4
−
0
View file @
d815cc06
...
@@ -197,6 +197,10 @@
...
@@ -197,6 +197,10 @@
self
.
_check_can_read
()
self
.
_check_can_read
()
return
self
.
_buffer
.
readline
(
size
)
return
self
.
_buffer
.
readline
(
size
)
def
__iter__
(
self
):
self
.
_check_can_read
()
return
self
.
_buffer
.
__iter__
()
def
readlines
(
self
,
size
=-
1
):
def
readlines
(
self
,
size
=-
1
):
"""
Read a list of lines of uncompressed bytes from the file.
"""
Read a list of lines of uncompressed bytes from the file.
...
...
This diff is collapsed.
Click to expand it.
Lib/gzip.py
+
4
−
0
View file @
d815cc06
...
@@ -398,6 +398,10 @@
...
@@ -398,6 +398,10 @@
self
.
_check_not_closed
()
self
.
_check_not_closed
()
return
self
.
_buffer
.
readline
(
size
)
return
self
.
_buffer
.
readline
(
size
)
def
__iter__
(
self
):
self
.
_check_not_closed
()
return
self
.
_buffer
.
__iter__
()
class
_GzipReader
(
_compression
.
DecompressReader
):
class
_GzipReader
(
_compression
.
DecompressReader
):
def
__init__
(
self
,
fp
):
def
__init__
(
self
,
fp
):
...
...
This diff is collapsed.
Click to expand it.
Lib/lzma.py
+
4
−
0
View file @
d815cc06
...
@@ -221,6 +221,10 @@
...
@@ -221,6 +221,10 @@
self
.
_check_can_read
()
self
.
_check_can_read
()
return
self
.
_buffer
.
readline
(
size
)
return
self
.
_buffer
.
readline
(
size
)
def
__iter__
(
self
):
self
.
_check_can_read
()
return
self
.
_buffer
.
__iter__
()
def
write
(
self
,
data
):
def
write
(
self
,
data
):
"""
Write a bytes object to the file.
"""
Write a bytes object to the file.
...
...
This diff is collapsed.
Click to expand it.
Misc/NEWS.d/next/Library/2021-04-12-15-15-50.bpo-43787.wCy_Wd.rst
0 → 100644
+
3
−
0
View file @
d815cc06
Add ``__iter__()`` method to :class:`bz2.BZ2File`, :class:`gzip.GzipFile`, and
:class:`lzma.LZMAFile`. It makes iterating them about 2x faster. Patch by
Inada Naoki.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment