[Python-Dev] Small any/all enhancement (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Wed Dec 28 11:00:41 CET 2005
- Previous message: [Python-Dev] Small any/all enhancement
- Next message: [Python-Dev] Small any/all enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Eric Nieuwland wrote:
all(o==0 for o in someobjects) ?
all() can be terminated at the first false element. For very long sequences this has important performance benefits. Besides, it makes all(seq,pred) the equivalent of pred(seq[0]) and pred(seq[1]) and pred(seq[2]) and ...
And so does the version with generator expressions: Alex' expression will also terminate with the first false statement; it is equivalent to some_objects[0]==0 and some_objects[1]==0 and ...
Regards, Martin
- Previous message: [Python-Dev] Small any/all enhancement
- Next message: [Python-Dev] Small any/all enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]