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


Groups > comp.lang.python > #9135

Re: What makes functions special?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.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 <ericsnowcurrently@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; '*not*': 0.05; 'suppose': 0.05; 'compiler': 0.07; 'interpreter': 0.07; 'python': 0.08; 'block.': 0.09; 'difference,': 0.09; 'executes': 0.09; 'function:': 0.09; 'interpreter,': 0.09; 'wrote:': 0.15; '*only*': 0.16; 'block,': 0.16; 'closures,': 0.16; 'compiler,': 0.16; 'elsewhere,': 0.16; 'somehow.': 0.16; '\xa0in': 0.16; 'cc:addr:python-list': 0.16; 'pm,': 0.16; 'def': 0.16; "wouldn't": 0.17; 'issue.': 0.19; 'language': 0.20; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'objects,': 0.23; 'pieces': 0.23; 'compiled': 0.23; 'code': 0.24; 'saying': 0.26; 'function': 0.26; "i'm": 0.27; 'url:mailman': 0.27; 'guess': 0.28; 'objects': 0.28; 'sat,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'interpret': 0.29; 'cc:addr:python.org': 0.30; 'thanks': 0.31; 'subject:?': 0.31; 'url:listinfo': 0.32; 'source': 0.32; 'it.': 0.33; 'instead': 0.34; 'it?': 0.34; 'there': 0.34; 'however,': 0.34; '(as': 0.34; 'function.': 0.35; 'subject:What': 0.35; 'then.': 0.35; 'pretty': 0.35; "isn't": 0.35; 'idea': 0.36; 'optimization': 0.36; 'url:python': 0.37; 'opposed': 0.37; 'but': 0.37; 'could': 0.37; 'using': 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; 'question,': 0.38; 'steven': 0.38; 'think': 0.38; 'put': 0.38; 'case': 0.39; 'received:209': 0.40; 'called': 0.40; 'did': 0.40; 'your': 0.60; 'taking': 0.65; 'received:209.85.215.174': 0.67; 'received:mail- ey0-f174.google.com': 0.67; 'special': 0.67; 'quality': 0.74; 'compiles': 0.84; 'difference.': 0.84; 'snow': 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=bMwx1Snv7/Gl62oONMU/X7hKN/kQUYH3CnL2zmmLP2o=; b=at2nd2wir6KkL8zzg4npqOA0mfNHnKM9ZFOxXUJoU6I+lzxt5DVS3CjjYjjSkgn+F/ Wzj9RP1eebo8uK2Pf5wDJ98JjPZeHOq1K3TMKyhh+gBPOAo37f9ASxxaSfcA3qD4qT23 6Kuzgz0wFG1dgsC+FL/DqMq1c5Z11lkJWmdRc=
MIME-Version 1.0
In-Reply-To <4e1901bb$0$29994$c3e8da3$5496439d@news.astraweb.com>
References <CALFfu7Cd4jmZGfCPpz58Me+ar5w4O02x1TN9AtSMtkTK11Bsqg@mail.gmail.com> <ivarbq$g20$1@dough.gmane.org> <mailman.811.1310260259.1164.python-list@python.org> <4e1901bb$0$29994$c3e8da3$5496439d@news.astraweb.com>
Date Sat, 9 Jul 2011 20:33:10 -0600
Subject Re: What makes functions special?
From Eric Snow <ericsnowcurrently@gmail.com>
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>
Content-Type text/plain; charset=ISO-8859-1
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 <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.816.1310265192.1164.python-list@python.org> (permalink)
Lines 68
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1310265192 news.xs4all.nl 21831 [2001:888:2000:d::a6]:47994
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:9135

Show key headers only | View raw


On Sat, Jul 9, 2011 at 7:34 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Eric Snow wrote:
>
>> Mostly I am just
>> trying to put together more pieces of the Python puzzle.  In this case
>> I was trying to find out if the optimized execution of code objects
>> for functions is a part of the language or just an implementation
>> detail.
>
> You keep using that phrase, "optimized execution of code objects for
> functions", but I have no idea what that means.
>
> The best I can think of is that you are thinking along these lines...
>
> "Suppose we have the source code to a function:
>
> def spam(n):
>    return "SPAM"*n
>
> To execute this, Python currently compiles the function into a code block,
> and then when you call spam(n) elsewhere, Python executes the already
> compiled code block.
>

Yeah, that's pretty much it.  Is that all there is to it?  I was
saying optimized, but I guess there isn't much special optimization
going on then.  Thanks for taking the time.

-eric

> Suppose instead an implementation of Python did not pre-compile the
> function. Each time you called spam(n), the implementation would have to
> locate the source code and interpret it on the spot. Would that be
> allowed?"
>
> If that's your question, then I would call that a Python interpreter using
> c.1960 technology (as opposed to a byte-code compiler, which all the main
> implementations currently are).
>
> If that were the *only* difference, then I see no reason why it wouldn't be
> allowed as an implementation of Python. A horribly slow implementation, but
> still an implementation.
>
> However, I doubt that would be the only difference. Given such a
> simple-minded Python interpreter, it would be hard to provide expected
> Python language features such as compiled code objects, closures, etc. You
> would have to fake them somehow. Provided you could fake them sufficiently
> well, then the lack of a byte-code compiler is just a quality of
> implementation issue.
>
> If that's *not* your question, them I'm stumped.
>
>
>
>
> --
> Steven
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Re: What makes functions special? Eric Snow <ericsnowcurrently@gmail.com> - 2011-07-09 19:10 -0600
  Re: What makes functions special? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-10 11:34 +1000
    Re: What makes functions special? Eric Snow <ericsnowcurrently@gmail.com> - 2011-07-09 20:33 -0600
    Re: What makes functions special? Terry Reedy <tjreedy@udel.edu> - 2011-07-10 00:04 -0700

csiph-web