File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1818import tempfile
1919import itertools
2020
21+ try :
22+ memoryview (b'' )
23+ except NameError :
24+ memoryview = lambda x : x
25+
2126#
2227# Constants for shape types
2328NULL = 0
@@ -389,10 +394,12 @@ def __shapeIndex(self, i=None):
389394 numRecords = shxRecordLength // 8
390395 # Jump to the first record.
391396 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 ()
394401 # 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 ] ]
396403 if not i == None :
397404 return self ._offsets [i ]
398405
You can’t perform that action at this time.
0 commit comments