Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9121

Re: What makes functions special?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'distinction': 0.07; 'rest,': 0.07; 'terry': 0.07; 'python': 0.08; 'defined,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'tracker': 0.09; 'wrote:': 0.15; '2:28': 0.16; 'asking.': 0.16; 'caching': 0.16; 'reedy': 0.16; 'pm,': 0.16; 'that?': 0.19; 'discussion': 0.22; 'header:In-Reply-To:1': 0.22; 'code.': 0.22; 'code': 0.24; 'modules': 0.25; 'statement': 0.25; 'function': 0.26; 'objects': 0.28; 'compile': 0.29; 'object': 0.30; 'definition': 0.30; 'modules,': 0.30; 'objects.': 0.30; 'subject:?': 0.31; 'pure': 0.32; 'actually': 0.33; 'to:addr:python-list': 0.34; 'header:X -Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; 'there': 0.34; 'compilation': 0.35; 'module.': 0.35; 'subject:What': 0.35; 'file': 0.36; 'issue': 0.37; 'received:cox.net': 0.37; 'but': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'eric': 0.38; 'execution': 0.38; 'case': 0.39; 'header:Mime-Version:1': 0.39; '[1]': 0.39; 'got': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'happen': 0.62; 'body': 0.63; 'details': 0.65; 'special': 0.67; 'execution.': 0.84; 'special.': 0.84; 'snow': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: What makes functions special?
Date Sat, 09 Jul 2011 17:21:28 -0700
References <CALFfu7Cd4jmZGfCPpz58Me+ar5w4O02x1TN9AtSMtkTK11Bsqg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host wsip-72-214-0-82.sd.sd.cox.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20110624 Thunderbird/5.0
In-Reply-To <CALFfu7Cd4jmZGfCPpz58Me+ar5w4O02x1TN9AtSMtkTK11Bsqg@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.808.1310257357.1164.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1310257357 news.xs4all.nl 21866 [2001:888:2000:d::a6]:52019
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:9121

Show key headers only | View raw


On 7/9/2011 2:28 PM, Eric Snow wrote:
> A tracker issue [1] recently got me thinking about what makes
> functions special.  The discussion there was regarding the distinction
> between compile time (generation of .pyc files for modules and
> execution of code blocks), [function] definition time, and [function]
> execution time.  Definition time actually happens during compile time,

Not true. For main modules, execution of each statement immediately 
follows compilation, but not for other modules, where compilation and 
caching of code objects may happen years before the function object is 
created.

> Functions are a special case in Python for providing a more optimized
> execution of a code block in pure Python code.  And how is that?  When
> the function is defined, a code object is generated for the function
> body along with a few "static" details that will be used during
> execution.  No other objects have code objects.  No other objects in
> Python have this special optimization.

A .pyc file is a serialized code object for a module.

As for the rest, I am not sure what you are asking.

Terry Reedy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: What makes functions special? Terry Reedy <tjreedy@udel.edu> - 2011-07-09 17:21 -0700

csiph-web