Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7519
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'subject:two': 0.07; 'subject:compare': 0.09; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail-iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'angelico': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'intersection': 0.16; 'subject:similar': 0.16; 'tue,': 0.17; 'header:In-Reply-To:1': 0.21; 'variable': 0.21; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'subject:?': 0.29; 'lists': 0.29; 'to:addr:python-list': 0.33; 'operations': 0.33; 'chris': 0.34; 'subject:What': 0.35; 'using': 0.35; 'subject:lists': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.37; 'two': 0.37; 'subject:: ': 0.38; '8bit%:6': 0.39; 'skip:s 20': 0.39; "i'd": 0.39; 'received:209': 0.39; 'sets': 0.39; 'to:addr:python.org': 0.39; 'making': 0.67; 'sets,': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=IxXI1kq00G80sMfQOWKj8cJKGNR13L1XyM+Zm+XNPW4=; b=FZBmv/9SExAXyO4KcCmJCrh5Frsku2/7pWZyl+AbCfUQ2H+HRjnhGCQZcZ7k4hxPeN pdbc8Na/R2RSHrlHOw09mS1rSH7EBVAWZPHiOXIaVR9OG9vPbSBfPil4FRYkgZ3+GmVL mjZ5vdQHOmiX06d38N87AoCiUptf6rYZXJw6o= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=OrQeD3QsaUYblcZg+bbVnR9WRkGYyGF9g04xQpuL1dO6mPR9n9+HtzlgOWjRvRXoZ9 ktj4SxE1QiL1TdsX2O9fEzsNWxEvVgZZCthzOhB1L/l+c0Eta8GEPLkuCTusUP4g77c0 tbSu3B2w28F36dAQVJ8+tdDkePZuMcqOzzCbw= |
| MIME-Version | 1.0 |
| In-Reply-To | <3ff2f4cc-7c26-4f59-9463-d6f0874174d8@dn9g2000vbb.googlegroups.com> |
| References | <3ff2f4cc-7c26-4f59-9463-d6f0874174d8@dn9g2000vbb.googlegroups.com> |
| Date | Tue, 14 Jun 2011 01:09:07 +1000 |
| Subject | Re: What is the most efficient way to compare similar contents in two lists? |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.169.1307977750.11593.python-list@python.org> (permalink) |
| Lines | 16 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1307977750 news.xs4all.nl 49048 [::ffff:82.94.164.166]:59731 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7519 |
Show key headers only | View raw
On Tue, Jun 14, 2011 at 12:58 AM, Zachary Dziura <zcdziura@gmail.com> wrote: > if set(source_headers) == set(target_headers): > similar_headers = len(source_headers) Since you're making sets already, I'd recommend using set operations - same_headers is the (length of the) intersection of those two sets, and different_headers is the XOR. # If you need the lists afterwards, use different variable names source_headers = set(source_headers) target_headers = set(target_headers) similar_headers = len(source_headers & target_headers) different_headers = len(source_headers ^ target_headers) Chris Angelico
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What is the most efficient way to compare similar contents in two lists? Zachary Dziura <zcdziura@gmail.com> - 2011-06-13 07:58 -0700
Re: What is the most efficient way to compare similar contents in two lists? Chris Angelico <rosuav@gmail.com> - 2011-06-14 01:09 +1000
Re: What is the most efficient way to compare similar contents in two lists? Zachary Dziura <zcdziura@gmail.com> - 2011-06-13 08:21 -0700
Re: What is the most efficient way to compare similar contents in two lists? Chris Angelico <rosuav@gmail.com> - 2011-06-14 01:39 +1000
Re: What is the most efficient way to compare similar contents in two lists? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-13 16:04 +0000
Re: What is the most efficient way to compare similar contents in two lists? Chris Angelico <rosuav@gmail.com> - 2011-06-14 02:30 +1000
Re: What is the most efficient way to compare similar contents in two lists? geremy condra <debatem1@gmail.com> - 2011-06-13 10:46 -0700
Re: What is the most efficient way to compare similar contents in two lists? Chris Angelico <rosuav@gmail.com> - 2011-06-14 03:50 +1000
Re: What is the most efficient way to compare similar contents in two lists? geremy condra <debatem1@gmail.com> - 2011-06-13 11:20 -0700
Re: What is the most efficient way to compare similar contents in two lists? Chris Angelico <rosuav@gmail.com> - 2011-06-14 04:24 +1000
Re: What is the most efficient way to compare similar contents in two lists? Ethan Furman <ethan@stoneleaf.us> - 2011-06-13 12:11 -0700
Re: What is the most efficient way to compare similar contents in two lists? Zachary Dziura <zcdziura@gmail.com> - 2011-06-13 12:21 -0700
Re: What is the most efficient way to compare similar contents in two lists? Chris Angelico <rosuav@gmail.com> - 2011-06-14 07:33 +1000
Re: What is the most efficient way to compare similar contents in two lists? Chris Angelico <rosuav@gmail.com> - 2011-06-14 04:11 +1000
Re: What is the most efficient way to compare similar contents in two lists? Chris Torek <nospam@torek.net> - 2011-06-13 18:40 +0000
Re: What is the most efficient way to compare similar contents in two lists? Chris Angelico <rosuav@gmail.com> - 2011-06-14 04:12 +1000
csiph-web