Hello,
I have the following issue: when I try to create symbols (and by extension expressions) in different processes, SymPy somehow does not detect that the symbols are the same even though they have the same name and assumptions.
As an example, consider the following code snippet and the respective output:
import multiprocessing as mp
import sympy as sp
VAR_X = sp.Symbol('x', real=True, nonzero=True)
def process():
return sp.Symbol('x', real=True, nonzero=True)
if __name__ == '__main__':
a1 = sp.Symbol('a', real=True, nonzero=True)
a2 = sp.Symbol('a', real=True, nonzero=True)
print(a1, a2, a1 == a2, a1 - a2, '\n')
pool = mp.Pool(4)
jobs = []
for _ in range(5):
jobs.append(pool.apply_async(process))
symbols = []
for job in jobs:
symbols.append(job.get())
pool.close()
for s in symbols:
print(s, ' | ', VAR_X, ' | ', s - VAR_X, ' | ', sp.simplify(s - VAR_X))
Output:
a a True 0
x | x | -x + x | -x + x
x | x | -x + x | -x + x
x | x | -x + x | -x + x
x | x | -x + x | -x + x
x | x | -x + x | -x + x
Has anyone seen this before? Can anyone explain me what is going on?
Thank you,
Momchil