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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '(using': 0.07; 'subject:code': 0.07; 'subject:How': 0.10; 'times,': 0.14; '(same': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'guessing': 0.16; 'numpy': 0.16; 'subject:make': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'header:User-Agent:1': 0.23; "i've": 0.25; 'suggested': 0.26; 'post': 0.26; 'header:In-Reply- To:1': 0.27; 'tried': 0.27; 'idea': 0.28; 'function': 0.29; 'am,': 0.29; "i'm": 0.30; 'code': 0.31; 'faster,': 0.31; 'piece': 0.31; "we're": 0.32; 'run': 0.32; 'quite': 0.32; 'convert': 0.35; 'everyone.': 0.36; 'subject:?': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'ability': 0.39; 'expensive': 0.39; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'email addr:gmail.com': 0.63; 'results': 0.69; 'subject:this': 0.83 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Sun, 21 Jul 2013 09:27:36 -0600 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: How can I make this piece of code even faster? References: <6bf4d298-b425-4357-9c1a-192e6e6cd9f0@googlegroups.com> <9a207133-1f52-414a-bbbd-581bcee8dc93@googlegroups.com> In-Reply-To: <9a207133-1f52-414a-bbbd-581bcee8dc93@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 9 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374421840 news.xs4all.nl 15875 [2001:888:2000:d::a6]:34395 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51015 On 07/21/2013 04:19 AM, pablobarhamalzas@gmail.com wrote: > Thank's for all the replies! I've tried some of the imporovements you suggested (using math.exp() and sum() or math.fsum()). > None of that made the code faster, because they are functions you are calling lots of times, and function calling is quite time expensive (same as x**(1/2) is faster than math.sqrt(x)). > > I'm going to try to convert tu numpy now (I have no idea how to do it at the moment), thank's again to everyone. Perhaps you'd have better results if you'd post a runnable piece of code. Otherwise we're just guessing since no one has the ability to actually run your code.