Python vs. Ruby

"Martin v. Löwis" martin at v.loewis.de
Tue Dec 31 12:12:30 EST 2002


Francis Burton wrote:
> What difference does this make in practice? Is there somewhere I
> can read about "native" vs "user" threads?

I guess there are many places on the net to read about this; this 
distinction is fundamental, and probably discussed in any decent 
introduction to threads. Essentially, user-level threads are implemented 
without aid by the operating system; context-switches are initiated by 
the application itself, rather than through preemption by the operating 
system.

As the result, you won't see context switches in certain states in a 
user-thread library, whereas thread switches can occur at any point when 
using native threads. Also, the operating system can decide to run two 
threads simultaneously on two processors in a multiprocessor machine. 
For Python, the global interpreter lock takes away part of the 
flexibility of native threads.

Comparing the two approaches in practice is only meaningful if you have 
specific applications for which to compare them. For Python vs. Ruby, 
the most notable difference is that blocking system calls block all 
threads in Ruby, and just the calling thread in Python.

Regards,
Martin




More information about the Python-list mailing list