questions about scope/threading

eugene kim eugene1977 at hotmail.com
Thu Oct 17 02:22:20 EDT 2002


well, i'm really confused..
these are from python essential reference by david m.beazley

The scheduling of threads and thread switching is tightly controlled by a 
global interpreter lock that allows only a single thread of execution to be 
running in the interpreter at once.
: what does this mean? i thought threads are supposed to be running in 
parrellel.

Thread switching can only occur between the execution of individual 
bytecodes in the interpreter.
: what is 'individual bytecodes' ? is one python statement supposed to have 
many bytecodes?(just like c & assembly)

 Threads share global variables.
The trick with Python is that ALL objects are truly global
: ?? i 'm really confused, what is refered as global? i thought 'var1' is 
only global here on below example.
<file start>
var1 = 1

class Class1:
   self.var2 = 2
   var3 = 3

class Class2(threading.Thread)
   self.var4 = 4
   var5 = 5
   def method1(self):
       var6 = 6
<file end>

thank you



More information about the Python-list mailing list