Python使用GIL(
全球翻译锁
),它可以防止多个线程一次执行Python字节码。换句话说,一次只执行一个线程,因此在您的情况下几乎不可能实现任何显着的性能提升。
你应该尝试使用Python
多处理池
相反,它不受GIL的限制:
from multiprocessing import Pool
…
pool = Pool(5)
company_items = pool.map(group_comp_with_coord, test.iterrows())
…
</code>