In article <[EMAIL PROTECTED]>, Douglas Alan <[EMAIL PROTECTED]> wrote:
> > Cetainly, if <yield_all > > iterator> == <for i in iterator: yield i>, I don't see how anything > > is gained except for a few keystrokes. > > What's gained is making one's code more readable and maintainable, > which is the one of the primary reasons that I use Python. I don't see a lot of difference in readability and maintainability between the two versions. And if yield_all is going to expand into the loop, anyway, I'd prefer to make that obvious by using the for-loop version, rather than using a keyword and pretending that passing the iterators on has no overhead. If we're talking about machinery behind the scenes to shortcut chains of yield_all's, so that the time to pass items up through the chain is smaller than it would be in the for-loop case, I'd think that would be a better reason for a keyword, because it's not something that can be done very easily without one in the current language. I don't know how to make such shortcutting machinery faster than logarithmic in the worst case (taking into account the possibility that multiple generators could have yield_all's to the same iterator) but I think it could be made nearly constant time in most situations. On the other hand, I'm not convinced that this would be needed frequently enough to warrant the complexity of trying to optimize it. -- David Eppstein Computer Science Dept., Univ. of California, Irvine http://www.ics.uci.edu/~eppstein/ -- http://mail.python.org/mailman/listinfo/python-list