[melbourne-pug] stackless python question

Tennessee Leeuwenburg tleeuwenburg at gmail.com
Wed Apr 1 01:27:50 CEST 2009


This is just what I think, not what I know.

Concurrent processing is faster only when you can do two things at once, and
not otherwise.

Multi-threaded programming is concerned with making sure multiple paths of
execution all get fair time-share of the CPU, so that the GUI painting can
get a bit of CPU time every now and then even while other stuff is going on.
However, a simple for loop will execute no quicker multi-threaded than
single-threaded.

For some reason which I genuinely don't understand, lots of people hate this
thing called the global intepreter lock, which basically means that only one
thread can own that lock at any one time. This is needed in order to
guarantee "stuff" in Python's core, mostly reference counts for garbage
collection. However, when you've got only one CPU, it's self-obvious that
you can only do one thing at a time. So it just doesn't matter that there is
a global interpreter lock. The argument against threading without the GIL is
that you need to spend more time maintaining your threads, such that you
don't get any advantages from it. So all your Python stuff runs in a single
operating-system thread, and your "python threads" get time-share of
Python's CPU share, rather than having multiple OS-level Python threads
running. But I still don't see what having multiple OS-level threads buys
you.

What's faster is doing two things at the same time, by utilising multiple
CPUs. That's real concurrency, and *is* faster, but it doesn't require
Stackless either. pyprocessing (2.x) or multiprocessing (3.x) will give you
multiple processes so that you can do two things at once.

My guess is that there are some cases where Stackless is either actually
faster, or just more elegant, than regular CPython, but I wouldn't bet on
it. If it was Just Better, then everyone would be using it.

Cheers,
-T

On Tue, Mar 31, 2009 at 9:21 PM, John Thorn <swifteye2 at msn.com> wrote:

>
>        Hello
>              I am a beginner at Python. My question:
>
>              What advantages does Stackless python have over normal python?
> If the concurrent programming of stackless python IS faster, then why wasn't
> python stackless in the first place? Or is there some downside to stackless
> python that complicates the issue?
>
>            Regards
>            Clive
>
> ------------------------------
> Find car news, reviews and more Looking to change your car this year?<http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT>
>
> _______________________________________________
> melbourne-pug mailing list
> melbourne-pug at python.org
> http://mail.python.org/mailman/listinfo/melbourne-pug
>
>


-- 
--------------------------------------------------
Tennessee Leeuwenburg
http://myownhat.blogspot.com/
"Don't believe everything you think"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/melbourne-pug/attachments/20090401/a200bc95/attachment-0001.htm>


More information about the melbourne-pug mailing list