Author rhettinger
Recipients ethan.furman, ezio.melotti, hynek, loewis, lukasz.langa, mark.dickinson, ncoghlan, pitrou, r.david.murray, raduv, rhettinger, serhiy.storchaka, tim.peters
Date 2014-02-24.16:09:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
As soon as the trunk opens again, I'll add Nick's version to the itertools  recipes section.  

I'm disinclined to add it directly to the itertools module as a native C function for several reasons:

* The problem solved isn't that common (very little of code I've ever written or seen would be better-off if this function had been available).   The OP's regex use case was shown by Martin to be better written as an explicit for-loop.  I think this is probably also true in the general case.

* The module unity is about creating iterators.  Consumers of iterators such as any(), all(), next(), sum(), min(), max() and others all lie elsewhere. 

* For-loops are likely to be the one obvious way to do it for other variants such first_false(), first_true_raise_exception_if_not_found(),
 or first_greater_than_limit(), etc.

* For the most part, the functional style of itertool composition has been a win for performance, but not for readabilty.  Also, users of the module seem to suffer from having-too-many-choices.  Accordingly, I only want to grow the module for cases where there is a clear win.

I would have pronounced on this one sooner but was stayed by the enthusiasm of the participants in this thread.

David said, "now I have a place in the non-test email code where using this would lead to easier-to-read code".   IMO, this is telling.  The bar is higher than "I would have used this one time".  That doesn't make it worth having to learn and remember.
Date User Action Args
2014-02-24 16:09:19rhettingersetrecipients: + rhettinger, tim.peters, loewis, mark.dickinson, ncoghlan, pitrou, ezio.melotti, r.david.murray, ethan.furman, lukasz.langa, hynek, serhiy.storchaka, raduv
2014-02-24 16:09:19rhettingersetmessageid: <>
2014-02-24 16:09:19rhettingerlinkissue18652 messages
2014-02-24 16:09:18rhettingercreate