Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.053 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; "'',": 0.07; '3),': 0.09; 'jan': 0.12; 'bytecode': 0.16; 'comparison.': 0.16; 'parse,': 0.16; 'sec': 0.16; 'subject:skip:e 10': 0.16; 'test).': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'parse': 0.24; 'looks': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; '100000': 0.31; 'stuff': 0.32; 'test': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'executing': 0.36; 'doing': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'read': 0.60; 'times': 0.62; "you've": 0.63; 'more': 0.64; 'between': 0.67; '10000': 0.68; '2015': 0.84; '2:02': 0.84; 'ratio': 0.91 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=AHmjW4VOOEVPddqlk375C/7kbQfmyDgKT9bn4/7xQ0Y=; b=LbepJnfr+VGDhajk9QImRrCOODYkXMzZMwHkbdAHXLbGEi3DLsPAiUBGejHAC8UQ6X bAozWpwxtO8ap6ZjEH9rVBymSF2qD9itH2vHO2m/BPazu8Ry14j9DUd8G5jFz9OGCO8S otu+GrebKs32bfB35z1elrFMUhEVoif5pg2xSB7KP6OiFWbLHU37BLii71DTQlbTvy0z WyUSrSc6/QQOgGnGLhylN7XPYUdX1plpmGD47x13EmJklh9ZJOI1kIliErqlyV7eUgBT puG2lB3G1qPf9Vh66X3uwvA1ILntwTpwJbZy2RAgnCQsfZkHuPgcp8VCayF9Sg/1JnfJ Ae4Q== X-Received: by 10.66.254.33 with SMTP id af1mr7382080pad.106.1421255513450; Wed, 14 Jan 2015 09:11:53 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <54b592ac$0$12995$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Wed, 14 Jan 2015 10:11:13 -0700 Subject: Re: Performance in exec environnements To: Python Content-Type: text/plain; charset=UTF-8 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: 1421255516 news.xs4all.nl 2863 [2001:888:2000:d::a6]:37087 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83769 On Wed, Jan 14, 2015 at 2:02 AM, Jean-Baptiste Braun wrote: > What I don't understand is the ratio between test 2 / 4 and test 1 / 3. > > Let 0.0229 sec be the execution time to read a bytecode (1st test). > Executing two times that bytecode takes 0.042 sec (test 3), which looks > coherent. > > Let 11.6 sec be the execution time to call the global exec, parse, do some > stuff and read a bytecode (test 2). I'm trying to understand why does doing > the same thing and reading one more bytecode is much longer (15.7 sec) in > comparison. You've also given it twice as much code to parse and compile. C:\Users\Ian>python -m timeit "compile('1 + 1', '', 'exec')" 100000 loops, best of 3: 16.8 usec per loop C:\Users\Ian>python -m timeit "compile('1 + 1; 1 + 1', '', 'exec')" 10000 loops, best of 3: 22.4 usec per loop