Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:two': 0.04; 'subject:code': 0.07; 'python': 0.08; 'files:': 0.09; 'subject:files': 0.09; 'am,': 0.12; 'def': 0.13; 'did,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'func():': 0.16; 'subject:contain': 0.16; 'tmp': 0.16; 'wrote:': 0.18; 'received:209.85.210.174': 0.21; 'received:mail- iy0-f174.google.com': 0.21; 'header:In-Reply-To:1': 0.22; '+0100,': 0.23; 'aggressive': 0.23; 'subject:same': 0.23; 'defined': 0.24; 'expect': 0.25; 'sat,': 0.25; 'code.': 0.26; 'code': 0.26; '"the': 0.26; 'message-id:@mail.gmail.com': 0.29; 'compile': 0.29; 'sun,': 0.30; 'quite': 0.31; 'file': 0.34; 'steven': 0.34; 'identical': 0.34; 'to:addr:python-list': 0.35; 'subject:How': 0.35; 'optimization': 0.36; 'two': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'think': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'fact,': 0.63; '11,': 0.68; 'subject:know': 0.93 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:to :content-type:content-transfer-encoding; bh=MQ2EX8kZ+LjGml/jaWSldRkNSUoysmgrXSBguVg4Hxg=; b=mGvlJfBl5reMds5T9DOG11FWCPBR8WeVF6tq4Tt9U/aIBDCs28QpPMyxTWOaCeFBJs IccsxKpElYl+BAE2MjzbgalsmgNSd1YUOSaTf9q+XIFqQBJWefosqVr2xM2pMv48i9CN kSqzocbvKBs4W+7mYAtQ2ZWVFg47d2hia0Wnz3+S7rcaAKKxceidq81BIC3gKwC+DClV dh0rW3AleaEhj8pj1aiJewXX/KLMv3okDvqwJci6rE8Zv/O/b4wkAJ1CdB2q7D9XJAhm Ts3dd97vFSh+gWWy3lz9gxqW1ggxll83R8TIk4Izrrnz9HmQMzltfyZe+/TQmKFQI/TC Fqew== MIME-Version: 1.0 In-Reply-To: <4f5bdb14$0$29891$c3e8da3$5496439d@news.astraweb.com> References: <4f5bdb14$0$29891$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 11 Mar 2012 12:15:11 +1100 Subject: Re: How to know that two pyc files contain the same code From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331428520 news.xs4all.nl 6921 [2001:888:2000:d::a6]:50979 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21475 On Sun, Mar 11, 2012 at 9:52 AM, Steven D'Aprano wrote: > On Sat, 10 Mar 2012 15:48:48 +0100, Gelonida N wrote: > Define "identical" and "the same". > > If I compile these two files: > > > # file ham.py > x =3D 23 > def func(): > =A0 =A0a =3D 23 > =A0 =A0return a + 19 > > > > # file =3D spam.py > def func(): > =A0 =A0return 42 > > tmp =3D 19 > x =3D 4 + tmp > del tmp > > > do you expect spam.pyc and ham.pyc to count as "the same"? They do not contain the same code. They may contain code which has the same effect, but it is not the same code. I don't think Python has the level of aggressive optimization that would make these compile to the same bytecode, but if it did, then they would _become identical_ per the OP's description - that they contain identical bytecode. In fact, I think the OP defined it quite clearly. ChrisA