Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.160 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.69; '*S*': 0.01; 'algorithm': 0.04; 'extension.': 0.16; 'manageable': 0.16; 'subject:generation': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'pointed': 0.19; 'written': 0.21; 'now?': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'room': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'url:python': 0.33; 'fri,': 0.33; 'could': 0.34; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'doubt': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; "you'll": 0.62; 'more': 0.64; 'mar': 0.68; 'yourself': 0.78; '100': 0.79; 'age': 0.80; '2015': 0.84; '9.6': 0.84; 'hundred': 0.95 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=22vIPa8XAh+9za6YZkVkRJuaa4fncYYwFy0fKr/WxYQ=; b=PXktDCeM2geEjAC9WqmMhN9U1a5HBvRxDcPHdRkvM8p+YGbbP26UzvSUXcQcmNcWM/ 1zQ2g6LKP9hhAt/iYd6ECvLddZ1qQON8L2vV3/pkrA9rAu2yrXxrQA8ozPFZIql/Q5ah lQVmhnCMF+96yGdAIXKs5ekUEyOo5Jrk+Hui3bf82TJuDGTBPWAWHuinfKdzxVW5SDi9 a6EiZgo5kSrryUqqZqcoqSmmHiBueAEt1qF2cle5qbBp7TkiF+1JSqJCeXHMdVHYj2VV GTP2KuRzhtaU64tGzo1rzQINdssA/5lmWkI0Wkjkd6OwaWMjMKrKCQN80qHUkb1GIXDa jrMg== X-Received: by 10.66.221.194 with SMTP id qg2mr27546312pac.106.1425662045784; Fri, 06 Mar 2015 09:14:05 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Fri, 6 Mar 2015 10:13:25 -0700 Subject: Re: Speeding up permutations generation To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425662054 news.xs4all.nl 2891 [2001:888:2000:d::a6]:35404 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87047 On Fri, Mar 6, 2015 at 1:24 AM, Abhiram R wrote: > >> >> A list of 100 elements has approximately 9.33 x 10**157 permutations. >> If you could somehow generate one permutation every yoctosecond, >> exhausting them would still take more than a hundred orders of >> magnitude longer than the age of the universe. >> -- >> https://mail.python.org/mailman/listinfo/python-list > > > True that :D I may have exaggerated on the number. Let's consider something > more practically manageable => 50 elements with a 50! permutation. > Is there a solution now? That's still infeasible, as others have pointed out. At one permutation every picosecond, you'll still need 9.6 x 10**44 years. If the size isn't that important to you and you just want a faster implementation of permutations, you could try reimplementing it yourself as a C extension. The stdlib implementation is already written in C though, so unless you have a better algorithm I doubt you'll find much room for optimization.