I only recently started studying python and there was a need to create a phylogenetic tree, however, due to its large size and GIL, it was extremely long.
I tried to make my own trial class. When trying to run a class method on multiple processes, the result was, however, the class method was actually executed twice.
import time
import multiprocessing
class Test:
def sum_data(self):
total = 0
for i in range(1, 10000):
for j in range(1, 10000):
total += i + j
print(f"The result is {total}")
def inter_funct():
object = Test()
object.sum_data()
if __name__ == '__main__':
starttime = time.time()
processes = []
for i in range(0, 2):
p = multiprocessing.Process(target=inter_funct)
processes.append(p)
p.start()
for process in processes:
process.join()
print('That took {} seconds'.format(time.time() - starttime))
Is it possible to combine the efforts of 2 processes on 1 object, rather than creating 2 processes and 2 objects?