I mean in multithreaded environment, do people share same cache (and same 
symbols)
If person1 created x=Symbol('x') and this is cached, and person2 created 
x=Symbol('x', positive=True), do they have separate x's or they mixed, so 
person1 can get positive x if it was overwritten in cache by person 2?



Reproduction.

from sympy import *
x = Symbol('x')
f = log(x)
a=Wild('a')
symbols = f.free_symbols
for symbol in symbols:
   f = f.subs(symbol, sympy.Symbol(symbol.name, positive=True))

print f.replace(log(a),log(Abs(a))) # prints log(x) as expected

# clear_cache() solves the problem

symbols = f.free_symbols
for symbol in symbols:
   f = f.subs(symbol, sympy.Symbol(symbol.name))

print f.replace(log(a),log(Abs(a))) # OOPS! prints log(x) instead of 
log(|x|)

On Wednesday, February 25, 2015 at 6:38:12 PM UTC+2, Joachim Durchholz 
wrote:
>
> Am 25.02.2015 um 17:04 schrieb Paul Royik: 
> > It appeared, that problem is with cache. 
> > Clearing cache solves the problem. 
> > 
> > Now, I want to ask, how cache is working in multithreaded environment? 
> > Do all people share same cache? 
>
> Actually I wouldn't expect caching to affect the outcome: at worst, the 
> same cache entry is computed twice, with the second entry overwriting 
> the first, identical entry. 
>
> Can you reproduce the problem in a single-threaded environment, with 
> caching enabled? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/513c22d4-d835-403e-9b2a-e9a1ec640f82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to