Skip to content

Commit

Permalink
[sheets-] speed up loading check of max_rows (#2636)
Browse files Browse the repository at this point in the history
For a sheet with millions of rows, the inner loop max_rows check was
delaying loading time by 60%.

-----

Co-authored-by: Saul Pwanson <code@saul.pw>
  • Loading branch information
midichef and saulpw authored Jan 4, 2025
1 parent 8f66127 commit 1223cf8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions visidata/sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,9 @@ def loader(self):
self.rows = []
try:
with vd.Progress(gerund='loading', total=0):
max_rows = self.options.max_rows
for i, r in enumerate(self.iterload()):
if self.precious and i > self.options.max_rows:
if self.precious and i >= max_rows:
break
self.addRow(r)
except FileNotFoundError:
Expand Down Expand Up @@ -1051,8 +1052,9 @@ def loader(self):

self.rows = []
# add the rest of the rows
max_rows = self.options.max_rows
for i, r in enumerate(vd.Progress(itsource, gerund='loading', total=0)):
if self.precious and i > self.options.max_rows:
if self.precious and i >= max_rows:
break
self.addRow(r)

Expand Down

0 comments on commit 1223cf8

Please # to comment.