Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36212
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: reduce expression to test sublist |
| Date | 2013-01-05 16:55 -0500 |
| References | <76cd3945-392e-40d4-9f87-d3956b9521d2@googlegroups.com> <50E877C2.8090208@davea.name> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.146.1357422994.2939.python-list@python.org> (permalink) |
On 1/5/2013 1:58 PM, Dave Angel wrote: > If you're trying to make a faster loop, then I suggest you look into set > differences. Turn both lists into sets, and subtract them. Something > like (untested): > > result = not bool( set(lst1) - set(lst2) ) This does not return False as soon as an item in set1 is found that is not in set2. set(lst1) < set(lst2) will, and directly return False/True. The OP is trying to compute the lst1 < lst2, where lst1 and lst2 are interpreted as sets, rather than as sequences with the lexicographic ordering default. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
reduce expression to test sublist Asim <asim.r.p@gmail.com> - 2013-01-05 10:25 -0800 Re: reduce expression to test sublist Dave Angel <d@davea.name> - 2013-01-05 13:58 -0500 Re: reduce expression to test sublist chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-05 11:59 -0800 Re: reduce expression to test sublist Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-01-05 22:41 +0200 Re: reduce expression to test sublist Terry Reedy <tjreedy@udel.edu> - 2013-01-05 16:55 -0500 Re: reduce expression to test sublist Terry Reedy <tjreedy@udel.edu> - 2013-01-05 16:55 -0500 Re: reduce expression to test sublist Dave Angel <d@davea.name> - 2013-01-05 17:05 -0500
csiph-web