Skip to content

Commit 4e3c3be

Browse files
committed
[sheets-] speed up loading check of max_rows
For a sheet with millions of rows, the inner loop max_rows check was delaying loading time by 60%.
1 parent ff489d3 commit 4e3c3be

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

visidata/sheets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,9 @@ def loader(self):
303303
self.rows = []
304304
try:
305305
with vd.Progress(gerund='loading', total=0):
306+
m = self.options.max_rows
306307
for i, r in enumerate(self.iterload()):
307-
if self.precious and i > self.options.max_rows:
308+
if self.precious and i == m:
308309
break
309310
self.addRow(r)
310311
except FileNotFoundError:
@@ -1051,8 +1052,9 @@ def loader(self):
10511052

10521053
self.rows = []
10531054
# add the rest of the rows
1055+
m = self.options.max_rows
10541056
for i, r in enumerate(vd.Progress(itsource, gerund='loading', total=0)):
1055-
if self.precious and i > self.options.max_rows:
1057+
if self.precious and i == m:
10561058
break
10571059
self.addRow(r)
10581060

0 commit comments

Comments
 (0)