I have a very CPU-intensive function:
def entity_intersections(ent, collidable):
intersections = []
for line1, line2 in product(ent.shape, collidable.shape):
pair_intersections = find_intersections(line1 + ent.position, ent.velocity, ent.acceleration, line2 + collidable.position, collidable.velocity, collidable.acceleration, ent, collidable)
intersections.extend(pair_intersections)
return intersections
I want to make all of the calls to find_intersections
run in parallel, so that they execute faster, while still gathering all of the results together (once all executions finish). What library would allow me to do this, given that find_intersections
is a pure function?
An example of how to generate these parallel executions, as well as gathering together the results would be greatly appreciated.