Skip to content

Commit 8f671db

Browse files
author
ARF
committed
__shapeIndex optimization: use list comprehension
x1.3 speedup over previous commit
1 parent 6e26248 commit 8f671db

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

shapefile.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,8 @@ def __shapeIndex(self, i=None):
389389
numRecords = shxRecordLength // 8
390390
# Jump to the first record.
391391
shx.seek(100)
392-
for r in range(numRecords):
393-
# Offsets are 16-bit words just like the file length
394-
self._offsets.append(unpack('>i4x', shx.read(8))[0] * 2)
392+
# Offsets are 16-bit words just like the file length
393+
self._offsets = [unpack('>i4x', shx.read(8))[0] * 2 for r in range(numRecords)]
395394
if not i == None:
396395
return self._offsets[i]
397396

0 commit comments

Comments
 (0)