Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:two': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; 'hmm.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'subject:based': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'subject:list': 0.30; 'subject:?': 0.36; '8bit%:86': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'received:46': 0.66; 'smith': 0.68; 'songs': 0.91; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: Split a list into two parts based on a filter? Date: Tue, 11 Jun 2013 18:28:31 +0300 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 46.211.125.186 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370964908 news.xs4all.nl 15924 [2001:888:2000:d::a6]:33452 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47666 11.06.13 01:50, Chris Angelico написав(ла): > On Tue, Jun 11, 2013 at 6:34 AM, Roy Smith wrote: >> new_songs = [s for s in songs if s.is_new()] >> old_songs = [s for s in songs if not s.is_new()] > > Hmm. Would this serve? > > old_songs = songs[:] > new_songs = [songs.remove(s) or s for s in songs if s.is_new()] O(len(songs)**2) complexity.