File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 18
18
import tempfile
19
19
import itertools
20
20
21
+ try :
22
+ memoryview (b'' )
23
+ except NameError :
24
+ memoryview = lambda x : x
25
+
21
26
#
22
27
# Constants for shape types
23
28
NULL = 0
@@ -389,10 +394,12 @@ def __shapeIndex(self, i=None):
389
394
numRecords = shxRecordLength // 8
390
395
# Jump to the first record.
391
396
shx .seek (100 )
392
- shxRecords = array .array ('i' , unpack (">" + "i4x" * numRecords ,
393
- shx .read ((4 + 4 ) * numRecords )))
397
+ shxRecords = array .array ('i' )
398
+ shxRecords .fromfile (shx , 2 * numRecords )
399
+ if sys .byteorder != 'big' :
400
+ shxRecords .byteswap ()
394
401
# Offsets are 16-bit words just like the file length
395
- self ._offsets = [2 * el for el in shxRecords ]
402
+ self ._offsets = [2 * el for el in memoryview ( shxRecords )[:: 2 ] ]
396
403
if not i == None :
397
404
return self ._offsets [i ]
398
405
You can’t perform that action at this time.
0 commit comments