Skip to content

Commit

Permalink
Use memoryview to avoid unnecessary copies while splitting Extras.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 14, 2023
1 parent 1b4bb55 commit 980ae60
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Lib/zipfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ def read_one(cls, raw):

@classmethod
def split(cls, data):
while data:
extra, data = _Extra.read_one(data)
# use memoryview for zero-copy slices
rest = memoryview(data)
while rest:
extra, rest = _Extra.read_one(rest)
yield extra

@classmethod
Expand Down

0 comments on commit 980ae60

Please sign in to comment.