Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'essentially': 0.04; 'heavily': 0.04; 'static': 0.04; 'cpython': 0.05; 'python)': 0.05; 'url:au': 0.05; 'subject:Python': 0.06; 'compiler': 0.07; 'modified': 0.07; 'pypy': 0.07; 'sys': 0.07; '#include': 0.09; 'main()': 0.09; 'optimizing': 0.09; 'run,': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'def': 0.12; 'a);': 0.16; 'cc:name:python list': 0.16; 'compilation,': 0.16; 'janssen': 0.16; 'main():': 0.16; 'optimised': 0.16; 'pypy.': 0.16; 'seconds.': 0.16; 'spurious': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'all.': 0.16; 'language': 0.16; 'wrote:': 0.18; '(not': 0.18; 'module': 0.19; 'examples': 0.20; '>>>': 0.22; 'example': 0.22; 'cc:addr:python.org': 0.22; '2.1': 0.24; 'compilation': 0.24; 'url:02': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'script': 0.25; 'post': 0.26; 'least': 0.26; 'header :In-Reply-To:1': 0.27; 'compared': 0.30; 'message- id:@mail.gmail.com': 0.30; 'went': 0.31; 'code': 0.31; '-0700,': 0.31; 'comparison': 0.31; "d'aprano": 0.31; 'decimal': 0.31; 'gcc': 0.31; 'noted': 0.31; 'purely': 0.31; 'steven': 0.31; 'subject:end': 0.31; 'though.': 0.31; 'this.': 0.32; 'run': 0.32; 'entirely': 0.33; 'possible.': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'module.': 0.36; 'version:': 0.36; "i'll": 0.36; 'seconds': 0.37; 'performance': 0.37; 'ahead': 0.38; 'massive': 0.38; 'that,': 0.38; 'making': 0.63; 'real': 0.63; 'more': 0.64; 'different': 0.65; 'url:blogspot': 0.65; 'skip:1 20': 0.65; 'between': 0.67; 'url:co': 0.67; 'optimized': 0.68; 'marketing': 0.70; 'url:2011': 0.75; 'believe,': 0.84; 'gains': 0.84; 'is)': 0.84; 'optimisation': 0.84; 'oscar': 0.84; 'ultimate': 0.93; '2013': 0.98 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 :cc:content-type; bh=y23jHWZl3soc55MhjgzKKoumSrBION8UQEGriUcDCMw=; b=wruiUVLctVMhZkn7yY8FEjruGecnRbOiDzZXsktHEKjmH9MEQQ+Utlm0DAuC0vIZsV TO1jL0rGeydOio7ZgEUgKYYwNkUpVREV9IzPpi1e6L2Q+FQ+H69utEmBUVmC7R78l1sX EBojJxJtzlsb3V4VmNsJfOx8k8gVoh+baAw6whb9T6whhoveJofFa/T2iVqmyfqh2Pc+ yqVBfLl55IpMHWYfBp2M4lpDIRMCX6EzC7nfnyxELe8JeFXCvwU7AsFNKppO/r18EYLf 4RjxLv9cVERjYESrDWdlpj0yf+g+QkFFOjyrZUdKUN4IHI7Ykivn1JhWJU38N4J+asin M0KQ== X-Received: by 10.58.238.9 with SMTP id vg9mr219037vec.43.1382349330241; Mon, 21 Oct 2013 02:55:30 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <5264dbbe$0$30000$c3e8da3$5496439d@news.astraweb.com> References: <4012031f-5334-4be8-a673-e0d8c8917fb2@googlegroups.com> <5264dbbe$0$30000$c3e8da3$5496439d@news.astraweb.com> From: Oscar Benjamin Date: Mon, 21 Oct 2013 10:55:10 +0100 Subject: Re: Python Front-end to GCC To: "Steven D'Aprano" Content-Type: text/plain; charset=ISO-8859-1 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: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382349341 news.xs4all.nl 15953 [2001:888:2000:d::a6]:56218 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57190 On 21 October 2013 08:46, Steven D'Aprano wrote: > On Sun, 20 Oct 2013 20:35:03 -0700, Mark Janssen wrote: > > [Attribution to the original post has been lost] >>> Is a jit implementation of a language (not just python) better than >>> traditional ahead of time compilation. >> >> Not at all. The value of jit compilation, I believe, is purely for the >> dynamic functionality that it allows. AOT compilation will never allow >> that, but in return you get massive performance and runtime-size gains > > On the contrary, you have that backwards. An optimizing JIT compiler can > often produce much more efficient, heavily optimized code than a static > AOT compiler, and at the very least they can optimize different things > than a static compiler can. This is why very few people think that, in > the long run, Nuitka can be as fast as PyPy, and why PyPy's ultimate aim > to be "faster than C" is not moonbeams: That may be true but both the examples below are spurious at best. A decent AOT compiler would reduce both programs to the NULL program as noted by haypo: http://morepypy.blogspot.co.uk/2011/02/pypy-faster-than-c-on-carefully-crafted.html?showComment=1297205903746#c2530451800553246683 > http://morepypy.blogspot.com.au/2011/02/pypy-faster-than-c-on-carefully-crafted.html > > http://morepypy.blogspot.com.au/2011/08/pypy-is-faster-than-c-again-string.html I just modified the add() example so that none of the operations can be entirely optimised away: def main(): i = 0 a = 0.0 b = 0.0 while i < 1000000000: a += 1.0 b += add(a, a) i += 1 print(b) Similarly for the C version: #include double add(double a, double b); int main() { int i = 0; double a = 0; double b = 0; while (i < 1000000000) { a += 1.0; b += add(a, a); i++; } printf("%f", b); } My timings: $ gcc -O3 x.c y.c $ time ./a.exe 1000000000134218000.000000 real 0m5.609s user 0m0.015s sys 0m0.000s $ time pypy y.py 1.00000000013e+18 real 0m9.891s user 0m0.060s sys 0m0.061s So the pypy version takes twice as long to run this. That's impressive but it's not "faster than C". I also compared a script that uses intensive decimal computation run under CPython 3.3 and PyPy 2.1 (pyver 2.7). This is essentially a comparison between the C implementation of the decimal module and pypy's jit'd optimisation of the pure Python module. CPython 3.3 takes 10 seconds and PyPy 2.1 takes 45 seconds. Again that's impressive (a lot of work went into making the C implementation of the decimal module as fast as it is) but it's not faster than C. I don't mean to criticise PyPy. I've just tested it and I am impressed and I think I'll definitely try and use it where possible. I do think that some of the marketing there is misleading though. Oscar