Skip to content

Commit

Permalink
[sheets-] speed up loading check of max_rows
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%.
  • Loading branch information
midichef committed Dec 15, 2024
1 parent ff489d3 commit 4e3c3be
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):
m = 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 == m:
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
m = 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 == m:
break
self.addRow(r)

Expand Down

0 comments on commit 4e3c3be

Please sign in to comment.