Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Pyhon 2.x or 3.x, which is faster? Date: Tue, 8 Mar 2016 02:31:11 +1100 Lines: 31 Message-ID: References: <87d1r6iltx.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de +huzUU/cEqeciTtcPqpKKw+FH0a8/sDob+ctnrkD6WWQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'broken': 0.03; 'interpreted': 0.07; 'cc:addr:python-list': 0.09; 'subject:which': 0.09; 'yeah,': 0.09; 'python': 0.10; '2016': 0.16; 'badly.': 0.16; 'decoding': 0.16; 'drag': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'impractical': 0.16; 'messy': 0.16; 'mixture': 0.16; 'old-style': 0.16; 'ported': 0.16; 'py3': 0.16; 'pythonic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'still,': 0.16; 'useless': 0.16; 'utterly': 0.16; 'wrote:': 0.16; 'implementing': 0.18; 'result,': 0.18; 'language': 0.19; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(the': 0.22; 'libraries': 0.22; 'file.': 0.22; 'trying': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; "doesn't": 0.26; 'external': 0.27; 'figure': 0.27; 'compare': 0.27; 'message- id:@mail.gmail.com': 0.27; 'function': 0.28; 'looks': 0.29; 'received:209.85.213.174': 0.29; "i'm": 0.30; 'classes': 0.30; 'code': 0.30; 'compared': 0.30; 'useful': 0.33; 'languages': 0.34; 'tue,': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'functions.': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'received:209.85': 0.36; '(and': 0.36; 'basic': 0.36; 'depends': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'no,': 0.38; "won't": 0.38; 'version': 0.38; 'received:209': 0.38; 'anything': 0.38; 'or,': 0.38; 'test': 0.39; 'easily': 0.39; 'still': 0.40; 'your': 0.60; 'course': 0.62; 'more': 0.63; 'here:': 0.63; 'mar': 0.65; 'yourself': 0.73; 'directly.': 0.76; 'actually,': 0.84; 'chrisa': 0.84; 'teeth': 0.84; 'to:none': 0.91; 'doubling': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=XrTXNqWQAEDv59dIneAu7guBdfBEY+NttvjDu7pViuc=; b=TmLAODZAkNuOodgqhl/NXlVMVrv3tjjJRH20CN+XCV5sHIWwer3JP3PUiBp3O9xBFO o6rtVHwh9k29p+UUXJxyeOAy/dBPj0MWXyOH1aL1951buZPZjG5ka9cXSlB6+Nxz7KcX cNq4QsoPKAsx80Cw5epicOvPW/oCpHUeX0HZbHQwgu3LFaE6eoHNBWs0/ZTaSLIGanIy CtzHYyX/PMzzuuB9vHXsEHFc8eRYDhLDDJeigWbnOKcWddPa36tgKqXhnd573r8a9Vs6 dx34mhka4EWptBT70MR68lvnSGeEJLn4OQgJzpjpvMI8LRCugM6D0QMau5KA2jBdb0pW o+Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=XrTXNqWQAEDv59dIneAu7guBdfBEY+NttvjDu7pViuc=; b=g+m4MB8lUZOV8E1Jeyi/XvD0hScBfWGOGo2/VjSWkHfea9xVre8QXCOjExI+eRYnLf wY7YJDc8J5T9smJdTBkhh830VVt32yh1Wuoj87bwcErx2oHaA7ljykbIcfJgnSgvhNee Ohn8GwejX11wsEj3k15Hz/qgUWI0eua4fpVQtx7W9wB0R/L1ZlJFZxxzim3PpcyKxa0e rW52e1vQmIH3e+5QT/OsYqBEtX5hxcfU+dp8FWoKrwroBL/Uw78h5RZEMiFF5TFDocwa WMjKZ/zU7AoSpdzTlGT+sZz4hJ4tV+dgE8T1wnQMEUP8mdLtiFlVOK+tJBMyJOzvMXcr AmHQ== X-Gm-Message-State: AD7BkJIg26iCMBAALJpnCrMIuewEoZw2rFcZC9Bgc3bOQGmgZaHNUgcXHaZ/oqTDrk/ASeM8oqICUA7hgCbgrw== X-Received: by 10.51.17.34 with SMTP id gb2mr12589641igd.13.1457364672107; Mon, 07 Mar 2016 07:31:12 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104215 On Tue, Mar 8, 2016 at 12:25 AM, BartC wrote: > No, I only compare basic language functions. I understand that Python > depends on complex built-in functions, and external libraries such as numpy, > for it to be used viably. But I'm also interested in using such languages > directly. > > Take the jpeg benchmark. Of course both Python and my language are > hopelessly slow and impractical compared with a C implementation, but this > is still a useful test (and in fact the interpreted version was used to more > easily develop a streamlined decoder that was then back-ported to C, > doubling its speed). > > (The Python version of that program is here: > http://pastebin.com/cHx3UhQb. It should work with any Python.) Actually, it won't work with any Python - not if it gets a broken file. Your abortjpeg() function doesn't work :) But what you have there is a messy mixture of old-style classes used as if they were C structs, array.array() as if it were a C array, and utterly uncommented code that looks like it was ported from, again, C. You're not going to prove anything useful about Python - any version of Python - by using it badly. Try implementing JPEG decoding in a more Pythonic way - or, better still, use pillow and don't write that kind of code yourself at all. Benchmarking Py2 vs Py3 on that kind of code is like trying to figure out whether it's easier to drag a 747 by your teeth or your toes. Yeah, you might get a result, but it's a useless one. ChrisA