Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed2.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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'output': 0.05; '(so': 0.07; 'subject:code': 0.07; 'input,': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'numpy': 0.16; 'subject:make': 0.16; 'appropriate': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'bit': 0.19; 'pfxlen:0': 0.19; 'network,': 0.22; 'cc:addr:python.org': 0.22; 'algorithms.': 0.24; 'helpful': 0.24; '(or': 0.24; 'question': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; "we're": 0.32; 'quite': 0.32; 'implemented': 0.33; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'subject:?': 0.36; 'seconds': 0.37; 'heard': 0.39; 'subject:can': 0.39; 'how': 0.40; 'simple': 0.61; 'making': 0.63; 'july': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'brain': 0.68; 'obvious': 0.74; 'subject:this': 0.83; 'calls,': 0.84; 'faster.': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=4qCZ1CfXgEEVwwYkiKJaqm9o0oixx/SuqLUfbN02JgE=; b=cwSd3dltzDrn0Dzkla1tBV6pF+IlvwHdyH04O9+P3oclxnw48/wbe8ISKjQLw1uccw v7GhJKShEFmMDW6H9inaLGCMon7WRvuIO5DFK7R7nU41m6G/14XP0sINWWEMyuvk7qrV n5ZPG+mjVR0+t9VDgE1GeFpDQfvPUG92L8DebOfZ/yOX+ga3JSLQOBrHxgB5QPz5UNMM Hq41pvJNJEnDbRCVFld/NKDgQayUwJyFL4eEeIa31pDSldvgZPeAFR8pAdqN4zlryxxt uskY3tkkUDzr/ICqLsyu9R4uqlZlKxWFJCmDDY3zCFZt3yFpUJFd3HrxH197GOJIB2Ve hQ9g== X-Received: by 10.112.88.169 with SMTP id bh9mr10475556lbb.12.1374406826622; Sun, 21 Jul 2013 04:40:26 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: <6bf4d298-b425-4357-9c1a-192e6e6cd9f0@googlegroups.com> References: <6bf4d298-b425-4357-9c1a-192e6e6cd9f0@googlegroups.com> From: Joshua Landau Date: Sun, 21 Jul 2013 12:39:46 +0100 X-Google-Sender-Auth: uPaBBfILx4zm9AdZGDO0O76WeA0 Subject: Re: How can I make this piece of code even faster? To: =?UTF-8?Q?Pablo_Barham_Alz=C3=A1s?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374406833 news.xs4all.nl 15879 [2001:888:2000:d::a6]:33198 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51008 On 20 July 2013 21:22, wrote: > Ok, I'm working on a predator/prey simulation, which evolve using genetic= algorithms. At the moment, they use a quite simple feed-forward neural net= work, which can change size over time. Each brain "tick" is performed by th= e following function (inside the Brain class): > > > The function is actually quite fast (~0.040 seconds per 200 calls, using = 10 input, 20 hidden and 3 output neurons), and used to be much slower until= l I fiddled about with it a bit to make it faster. However, it is still som= ewhat slow for what I need it. > > My question to you is if you an see any obvious (or not so obvious) way o= f making this faster. I've heard about numpy and have been reading about it= , but I really can't see how it could be implemented here. Currently we're just guessing; if you gave us an appropriate stand-in for "self" (so that we can call the function) we could be helpful much more easily.