wrapping yield ?

Michael Sparks Michael.Sparks at rd.bbc.co.uk
Fri Sep 13 06:55:09 EDT 2002


"Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message
news:Xns9288759449799duncanrcpcouk at 127.0.0.1...
> The syntax wouldn't look quite so bad if your function wasn't returning a
> value.

Problem is, it would in most situations, also I'm trying to keep the number
of generators to a minimum whilst a lower overhead than things like threads
and processes if I had several 10s of thousands going, keeping throughput
up may become an issue. (Hence the reason for wanting the functions called
part of the same generator rather than a separate, extra one)

> There definitely isn't any way to put a yield in a function and not have
it
> turn into a generator. When you yield from a generator, only a single
frame
> is saved, not a stack, so you can only yield from the outer loop.

Ah... that makes sense then...Pity - after all, "all you'd need" (looking at
it
simplistically) is a marker in the stack frame to tell the system how much
of the
stack to save. Amiga E had something very similar (from a use perspective)
for
determining how far back to throw exceptions without requiring the
equivalent
of try/(except|catch) blocks.

Thanks!


Michael.





More information about the Python-list mailing list