我想加快以下Cython代码。我正在考虑为HugeList提供一些指针数组的纯C对象,它需要通过Python进程分发到Worker函数的几个实例。 HugeList确实很大,特定索引的每个数组都适中。我可以在这个片段中改进什么:
from cpython cimport array
import array
from bisect import bisect_right
from zlib import decompress
def StructureBuilder(fileHandle):
HugeList = list()
with open(fileHandle, "r") as IndFile:
for line in IndFile:
HugeList.append(array.array('I', (decompress(eval(line)))))
return HugeList
def Worker(HugeList, unsigned long int index, unsigned int slice, unsigned int elem):
Slot = HugeList[index][:slice]
Position = bisect_right(Slot, elem)
return Position