Is python memory shared between theads?
Grant Edwards
grante at visi.com
Fri Dec 1 10:54:32 EST 2006
On 2006-12-01, Wesley Henwood <wesleyhenwood at hotmail.com> wrote:
> So I declare a variable named A in thread1, in script1.py. I assign
> the value of 2.5 to A. I then run script2.py in thread2. Script2.py
> assigns the value of 5.5 to a variable named A. Now, when thread1
> resums execution, I see that A = 5.5, rather than 2.5 as I expected.
>
> Is this normal behavior?
Yes. Threads share global namespace. From a CPU point of
view, they share a single address space.
> Based on the little documentation I have been able to find on
> this topic, it is normal behavior. The only way to use
> same-named variables in scripts is to have them run in a
> different process, rather than different threads.
Or make them local variables.
--
Grant Edwards grante Yow! If I felt any more
at SOPHISTICATED I would DIE
visi.com of EMBARRASSMENT!
More information about the Python-list
mailing list