Python based http server
Duncan Booth
duncan at NOSPAMrcp.co.uk
Mon Oct 13 04:29:13 EDT 2003
Doug <zr7m08j02 at sneakemail.com> wrote in
news:3F8993AD.4080404 at sneakemail.com:
> I thought the yield thing in Python 2.3 was a couritine implementation.
> Is there a difference between generators and coroutines?
(please don't top quote)
Coroutines have a completely separate stack which is saved when they yield,
so you have a load of nested function calls and yield from deep in the
middle of them.
Generators save only a single stack frame, so all yields must come directly
from the generator, not from functions which it calls.
You can use generators to get a similar effect to coroutines by nesting
generators and propogating the yields back up the chain, but this has to be
done explicitly at every level.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list