Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.031 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'created,': 0.09; 'executed': 0.09; 'python': 0.11; 'def': 0.12; 'subject:parameters': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'bit': 0.19; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'received:google.com': 0.35; 'i.e.': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'default': 0.69; '2015': 0.84; 'compiling': 0.84 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; bh=SEdxXk3QsbWlNUugmF5Pm6VCzE72Z4fj/0tMEyMsz+8=; b=IobCHQHVLi3PmEDm+xA8Jtsak6KP9vMe9geA+U+gMyYL/P1l12nnhB6cKHzArpjsXT guSLhbhBW7LHI3+LjKRrV7QB2whfNa+FLp8O+ks00V1wpAhVcyxK/QB4tZDgkzEsZtM7 MFoW6+i1sax0YjfT5VKutSr2daISE2Ndi1KseflDDj8Z7Gk7KBkhDrRVQx0VEyJM/qPC 9J+bDXIi97vZ1Rjb75xhq+2hRSlD6zYBBFKg+IgMSvQ5G5NW8c+3T5cRsVoKUzKzwAPh 2T49N0GuHxKo1BvS1OobqIxnZRTILnFux1Nad/F+q6s5AYaOVt99lcVaEP2NvCQXBLJU KiAw== MIME-Version: 1.0 X-Received: by 10.50.225.35 with SMTP id rh3mr5140549igc.29.1431100113044; Fri, 08 May 2015 08:48:33 -0700 (PDT) In-Reply-To: <554cd511$0$12979$c3e8da3$5496439d@news.astraweb.com> References: <72lu1cxvmg.ln2@news.c0t0d0s0.de> <554cd511$0$12979$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 8 May 2015 09:48:32 -0600 Subject: Re: functions, optional parameters From: Ian Kelly To: Python Content-Type: multipart/alternative; boundary=001a1132f214e05590051593f570 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431100115 news.xs4all.nl 2921 [2001:888:2000:d::a6]:41856 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90268 --001a1132f214e05590051593f570 Content-Type: text/plain; charset=UTF-8 On May 8, 2015 9:26 AM, "Steven D'Aprano" < steve+comp.lang.python@pearwood.info> wrote: > > Do you think that Python will re-compile the body of the function every time > you call it? Setting the default is part of the process of compiling the > function. To be a bit pedantic, that's not accurate. The default is evaluated when the function object is created, i.e. when the def statement is executed at runtime, not when the underlying code object is compiled. --001a1132f214e05590051593f570 Content-Type: text/html; charset=UTF-8

On May 8, 2015 9:26 AM, "Steven D'Aprano" <steve+comp.lang.python@pearwood.info> wrote:
>
> Do you think that Python will re-compile the body of the function every time
> you call it? Setting the default is part of the process of compiling the
> function.

To be a bit pedantic, that's not accurate. The default is evaluated when the function object is created, i.e. when the def statement is executed at runtime, not when the underlying code object is compiled.

--001a1132f214e05590051593f570--