Skip to content

Commit 4f20ee4

Browse files
committed
improve performance of FileIO.readall by using a list as result builder
1 parent 15a3b1c commit 4f20ee4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

graalpython/lib-python/3/_pyio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ def readall(self):
15781578
except OSError:
15791579
pass
15801580

1581-
result = bytearray()
1581+
result = []
15821582
while True:
15831583
if len(result) >= bufsize:
15841584
bufsize = len(result)
@@ -1592,9 +1592,9 @@ def readall(self):
15921592
return None
15931593
if not chunk: # reached the end of the file
15941594
break
1595-
result += chunk
1595+
result.append(chunk)
15961596

1597-
return bytes(result)
1597+
return b"".join(result)
15981598

15991599
def readinto(self, b):
16001600
"""Same as RawIOBase.readinto()."""

0 commit comments

Comments
 (0)