Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed6.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'plenty': 0.04; 'cpython': 0.05; 'differently.': 0.07; 'unexpected': 0.07; 'python': 0.08; 'least)': 0.09; 'object.': 0.09; 'question?': 0.09; 'tracker': 0.09; 'wrote:': 0.15; 'finney': 0.16; 'guessing': 0.16; 'objects?': 0.16; 'thinking.': 0.16; 'cc:addr:python-list': 0.16; 'pm,': 0.16; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'body.': 0.23; 'objects,': 0.23; 'works.': 0.23; 'code': 0.24; 'correctly.': 0.25; 'expect': 0.25; 'writes:': 0.25; 'function': 0.26; '(in': 0.26; 'url:mailman': 0.27; 'seeing': 0.28; 'language.': 0.28; 'objects': 0.28; 'right.': 0.28; 'sat,': 0.28; 'message- id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.30; 'do.': 0.30; 'differently': 0.30; 'objects.': 0.30; 'ran': 0.30; 'yes.': 0.30; 'least': 0.31; 'subject:?': 0.31; 'url:listinfo': 0.32; 'sufficient': 0.32; 'list': 0.32; 'does': 0.32; 'rather': 0.33; 'done': 0.33; "what's": 0.33; 'there': 0.34; 'describe': 0.34; 'subject:What': 0.35; 'define': 0.35; 'certain': 0.36; 'optimization': 0.36; 'url:python': 0.37; 'issue': 0.37; 'anything': 0.37; 'model': 0.37; 'but': 0.37; 'could': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'eric': 0.38; 'execution': 0.38; 'two': 0.38; 'perhaps': 0.39; 'got': 0.39; 'received:209': 0.40; 'skip:d 20': 0.40; 'give': 0.60; 'your': 0.60; 'internet': 0.64; 'facts': 0.64; 'received:209.85.215.174': 0.67; 'received:mail- ey0-f174.google.com': 0.67; 'special': 0.67; 'commercial': 0.70; 'failure': 0.73; 'clearer': 0.84; 'different.': 0.84; 'increase.': 0.84; 'confusion.': 0.91; 'snow': 0.91; 'way)': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=Hw9Oq1jpTslvxY0TWRUfVbIIHtIVN6G/OMVR7UVdx9U=; b=GgDTqL9WCm/9VK/eQZxyfjgz47e+UID3aEm112r0nSkAcr/C7Bp0Gr69KYVGjqXVZV kmhH5ijq9wUxZ1TvWaH/qIDYlWK337P8Wf2e+pkDpkI9nWag4Sh7U51RuXcnPOMOi5Xa ftrBtcJue1bZ9Jgyk/wfc7OM7vN1vijn25Prs= MIME-Version: 1.0 In-Reply-To: <87mxgngebf.fsf@benfinney.id.au> References: <87sjqfgjqg.fsf@benfinney.id.au> <87mxgngebf.fsf@benfinney.id.au> Date: Sat, 9 Jul 2011 19:28:02 -0600 Subject: Re: What makes functions special? From: Eric Snow To: Ben Finney Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: 67 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310261284 news.xs4all.nl 21789 [2001:888:2000:d::a6]:39921 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9128 On Sat, Jul 9, 2011 at 6:38 PM, Ben Finney wro= te: > Eric Snow writes: > >> On Sat, Jul 9, 2011 at 4:41 PM, Ben Finney = wrote: >> > Eric Snow writes: >> >> No other objects have code objects. No other objects in Python have >> >> this special optimization. >> > >> > Yes. The two facts are directly related. > [=85] > >> > Yes, functions are different and are treated differently. What's >> > your question? >> >> My point is that functions are special in Python because they provide >> a built in optimization via the special execution of code objects. > > Functions are special because they define a code object. > Right. But the point is that the code objects (in CPython at least) allow a special execution of the function body. What does that special execution give us? I am guessing a sufficient performance increase. Is there anything else? And do other Python implementations do anything special with code objects? I am not questioning why it was done a certain way, but rather trying to understand how Python works. >> I would like to know if it is really that big a deal > > Is *what* really that big a deal? > > Perhaps this could be clearer if you'd describe what it is that > surprises you, and how you'd expect it to be different. > I don't have any unexpected failure that I ran into or anything like that. I am just trying to learn more about the ins and outs of Python and that tracker issue got me thinking. And I know that there are plenty of people on this list that know a lot more about Python than I do. :) So I thought I would ask (in my own obscure way) if I was understanding the definition/execution model correctly. Sorry for any confusion. -eric >> and if the optimized execution of code objects is a CPython >> implementation detail or a specification of the language. > > I don't know that it's a specification. But functions result in code > objects, and other statements don't; I am not seeing why treating them > differently is surprising. > > -- > =A0\ =A0 =A0 =A0 =A0 =A0=93I see little commercial potential for the Inte= rnet for at | > =A0`\ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 least t= en years.=94 =97Bill Gates, 1994 | > _o__) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| > Ben Finney > -- > http://mail.python.org/mailman/listinfo/python-list >