On Fri, 20 Jan 2006 05:16:57 +0100, Peter Hansen wrote (in article <[EMAIL PROTECTED]>):
> I believe the more modern approach to this is to use generators in some > way, yield each other as the next state. This way you avoid all almost > all the function call overhead (the part that takes significant time, > which is setting up the stack frame) and don't have to resort to > bytecode hacks for better performance. Dumb question from a endless newbie scripting dilettant: Do you have a reference to a cookbook example for this method? Sidequestion: As I understand it, as a general rule generators are more efficient than functions in any case where the function is called several times, right? So basically if I want to write a long-running program in Python, it would make sense to code all functions that are likely to be called more than once as generators... TIA, Sincerely, Wolfgang Keller -- http://mail.python.org/mailman/listinfo/python-list