Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60965
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news.astraweb.com!border2.a.newsrouter.astraweb.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.120 |
| X-Spam-Level | * |
| X-Spam-Evidence | '*H*': 0.77; '*S*': 0.01; 'extracted': 0.09; 'mostly': 0.14; 'heapq': 0.16; 'loop.': 0.16; 'simpson': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'bit': 0.19; "haven't": 0.24; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "i'd": 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'thanks': 0.36; 'too': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'mentioned': 0.61; 'subject:more': 0.64; 'more': 0.64; 'believe': 0.68; 'nobody': 0.68; 'subject:there': 0.68; 'imagine': 0.93; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=liHeElBZTCXvn7Pb1WLB8yY9iribaVH9iNLzLsJmu1I=; b=mfIZTzdwZmoay37VTSK0VnsPjiL2mZEHbt7FIhCJTCQsJUEQuf3cqv8+Abg8mNlOS9 quNqdZWsgxZAHcS8U+eNoKEpwx3D7YBgpaaQuJN0xdpj55O6Myl4lOCfVkODdKZjEcG9 acLuJ/pu0rpjTt5hE34htTjN9biKkcktw4OIcqxjGxmhdgxfjwcAJ7Xrfs1pcEMDUgXR HNP/McQiQYBjHynfB9KRbdzZ+zKGyXfwr7dArJdILA7+xeMF+jWA0Wquf3rlWt63fg3G GciiGZpGUILnaznuyH3TSzZ6jMS1k1XQ8P5tZVahTIy06Gi+10s4swtZq5TtL5el4D3E q62Q== |
| X-Received | by 10.68.130.234 with SMTP id oh10mr41694030pbb.0.1386107030548; Tue, 03 Dec 2013 13:43:50 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <20131203211303.GA83257@cskk.homeip.net> |
| References | <bg60hjF83eoU1@mid.dfncis.de> <20131203211303.GA83257@cskk.homeip.net> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Tue, 3 Dec 2013 14:43:10 -0700 |
| Subject | Re: extracting a heapq in a for loop - there must be more elegant solution |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3532.1386107033.18130.python-list@python.org> (permalink) |
| Lines | 12 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386107033 news.xs4all.nl 2876 [2001:888:2000:d::a6]:38777 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:60965 |
Show key headers only | View raw
On Tue, Dec 3, 2013 at 2:13 PM, Cameron Simpson <cs@zip.com.au> wrote: > On 03Dec2013 12:18, Helmut Jarausch <jarausch@igpm.rwth-aachen.de> wrote: >> I'd like to extracted elements from a heapq in a for loop. >> I feel my solution below is much too complicated. >> How to do it more elegantly? > > I can't believe nobody has mentioned PriorityQueue. As far as I'm aware, the only advantage of PriorityQueue over heapq is that the former is thread-safe, which does not appear to be relevant here. I haven't tested it for speed, but I imagine it would be a fair bit slower, mostly thanks to the locking it needs to do.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
extracting a heapq in a for loop - there must be more elegant solution Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-12-03 12:18 +0000
Re: extracting a heapq in a for loop - there must be more elegant solution Peter Otten <__peter__@web.de> - 2013-12-03 13:38 +0100
Re: extracting a heapq in a for loop - there must be more elegant solution Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-12-04 09:36 +0000
Re: extracting a heapq in a for loop - there must be more elegant solution Peter Otten <__peter__@web.de> - 2013-12-04 10:50 +0100
Re: extracting a heapq in a for loop - there must be more elegant solution rusi <rustompmody@gmail.com> - 2013-12-03 04:40 -0800
Re: extracting a heapq in a for loop - there must be more elegant solution Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-12-04 09:37 +0000
Re: extracting a heapq in a for loop - there must be more elegant solution Duncan Booth <duncan.booth@invalid.invalid> - 2013-12-03 13:06 +0000
Re: extracting a heapq in a for loop - there must be more elegant solution Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-12-04 09:39 +0000
Re: extracting a heapq in a for loop - there must be more elegant solution Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-12-03 15:56 +0200
Re: extracting a heapq in a for loop - there must be more elegant solution Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-12-04 09:41 +0000
Re: extracting a heapq in a for loop - there must be more elegant solution Cameron Simpson <cs@zip.com.au> - 2013-12-04 08:13 +1100
Re: extracting a heapq in a for loop - there must be more elegant solution Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-12-04 09:44 +0000
Re: extracting a heapq in a for loop - there must be more elegant solution Cameron Simpson <cs@zip.com.au> - 2013-12-05 13:29 +1100
Re: extracting a heapq in a for loop - there must be more elegant solution Ian Kelly <ian.g.kelly@gmail.com> - 2013-12-03 14:43 -0700
Re: extracting a heapq in a for loop - there must be more elegant solution Ned Batchelder <ned@nedbatchelder.com> - 2013-12-03 17:32 -0500
csiph-web