Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!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.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'nested': 0.07; 'objects,': 0.09; 'subject:number': 0.09; 'runs': 0.10; 'python': 0.11; 'def': 0.12; 'filters.': 0.16; 'limit.': 0.16; 'nesting': 0.16; 'subject:skip:m 10': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'stack': 0.19; 'code,': 0.22; 'paul': 0.24; 'versions': 0.24; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'fault': 0.31; 'steven': 0.31; 'writes:': 0.31; 'subject:all': 0.32; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'yield': 0.36; 'filter': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'space': 0.40; 'eventually': 0.60; "you're": 0.61; "you'll": 0.62; 'limit': 0.70; 'prime': 0.74; 'soon,': 0.74; '2015': 0.84; 'nice,': 0.84; 'subject:find': 0.84 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=lTx97DDzfOSaE6PVKDJNHNcZjgvStYME1m3i3/trikU=; b=JXtDnnGK9alhBYG+ptdaD46Kem6V1ojVALyKYHnIJZLNprpyeymQ3YPfHDxE2jewa8 DpX+ZWL998sTCQQlQvz6Y4LFbDIYhUC2TZ5Z+mvwWhQHrpJipUc/xZsMYudlp+ZdUepv Ry3rHuVi5q5bCJASS4K7CUB28y/tXDDbVnIFTU+eTptM7P2/zqzv/Xvk6vAk7nHxgvEw hslDK0Nw9/KwMlgKKJsHX9uTlDghFwd7UB/CUgp0Tw+DZvl48fzzQuVHMyXlk7ZYhY4p b3BUBPmEzZ3872DIqJt+b3CNFA6ZC6mod+HaNx8c5kYrnGgJTDwYHGGwZJgVyA2HlIum laig== X-Received: by 10.42.37.5 with SMTP id w5mr32059128icd.39.1429113632256; Wed, 15 Apr 2015 09:00:32 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <871tjmyv4w.fsf@jester.gateway.sonic.net> References: <890bd388-f50a-4dec-9ef5-27715427472a@googlegroups.com> <55288135$0$12997$c3e8da3$5496439d@news.astraweb.com> <87egnrb3il.fsf@jester.gateway.sonic.net> <87619387c0.fsf@elektro.pacujo.net> <90a8e07c-adb3-499f-8971-4ea49f6aea4b@googlegroups.com> <87lhhx7r44.fsf@elektro.pacujo.net> <87zj6czt84.fsf@jester.gateway.sonic.net> <87vbh0zow3.fsf@jester.gateway.sonic.net> <87r3rozjjp.fsf@jester.gateway.sonic.net> <552b6e78$0$12985$c3e8da3$5496439d@news.astraweb.com> <87egnnzb0k.fsf@jester.gateway.sonic.net> <552d18df$0$13006$c3e8da3$5496439d@news.astraweb.com> <871tjmyv4w.fsf@jester.gateway.sonic.net> From: Ian Kelly Date: Wed, 15 Apr 2015 09:59:51 -0600 Subject: Re: find all multiplicands and multipliers for a number To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1429113657 news.xs4all.nl 2823 [2001:888:2000:d::a6]:57664 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88981 On Tue, Apr 14, 2015 at 8:37 PM, Paul Rubin wrote: > Steven D'Aprano writes: >> def turner(): >> nums = itertools.count(2) >> while True: >> prime = next(nums) >> yield prime >> nums = filter(lambda v, p=prime: (v % p) != 0, nums) > > This is nice, though it will still hit the nesting limit about equally > soon, because of the nested filters. I like the faster versions in the > O'Neill paper. Nope. You do end up with a lot of nested filter objects, but there's no recursion in the Python code, which means that you're not piling up frame objects, and you'll never hit the interpreter's recursion limit. You might eventually get a seg fault when the C stack space runs out, however.