[Python-Dev] 'stackless' python?

rushing at nightmare.com rushing at nightmare.com
Sat May 15 01:36:11 CEST 1999


Guido van Rossum writes:
 > > If Python had closures, then it would be a *little* easier, but would
 > > still make the average Pythoneer swoon.  Closures would let you put
 > > the above logic all in one method, but the code would still be
 > > 'inside-out'.
 > 
 > I forget how this worked :-(

[with a faked-up lambda-ish syntax]

def thing (a):
  return do_async_job_1 (a,
    lambda (b):
      if (a>1):
        do_async_job_2a (b,
          lambda (c):
            [...]
          )
      else:
        do_async_job_2b (a,b,
          lambda (d,e,f):
            [...]
          )
     )

The call to do_async_job_1 passes 'a', and a callback, which is
specified 'in-line'.  You can follow the logic of something like this
more easily than if each lambda is spun off into a different
function/method.

 > > I think that a web server built on such a Python could have the
 > > performance/scalability of thttpd, with the ease-of-programming
 > > of Roxen.  As far as I know, there's nothing like it out there.
 > > Medusa would be put out to pasture. 8^)
 > 
 > I'm afraid I haven't kept up -- what are Roxen and thttpd?  What do
 > they do that Apache doesn't?

thttpd (& Zeus, Squid, Xitami) use select()/poll() to gain performance
and scalability, but suffer from the same programmability problem as
Medusa (only worse, 'cause they're in C).

Roxen is written in Pike, a c-like language with gc, threads,
etc... Roxen is I think now the official 'GNU Web Server'.

Here's an interesting web-server comparison chart:

http://www.acme.com/software/thttpd/benchmarks.html

-Sam





More information about the Python-Dev mailing list