Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'static': 0.04; 'subject:Python': 0.06; 'variables': 0.07; 'arrays': 0.09; 'stack,': 0.09; 'anyway': 0.14; 'ah,': 0.16; 'expensive,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'variable.': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'days,': 0.24; 'specifies': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'wonder': 0.29; 'especially': 0.30; "d'aprano": 0.31; 'once,': 0.31; 'steven': 0.31; 'subject:end': 0.31; 'front': 0.32; "we're": 0.32; 'everyone': 0.33; 'received:84': 0.35; 'thanks': 0.36; 'too': 0.37; 'auto': 0.38; 'filled': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; "you're": 0.61; "you'll": 0.62; 'such': 0.63; 'our': 0.64; 'become': 0.64; 'header:Reply-To:1': 0.67; 'frank': 0.68; 'reply-to:no real name:2**0': 0.71; 'actually,': 0.84; 'difference.': 0.84; 'reply- to:addr:python.org': 0.84; 'whereas': 0.91; '2013': 0.98 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=PIY2p5aC c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=05MOGALpfCEA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=pJCV8e6cc5sA:10 a=lGzNwBHlkixmNzWafv0A:9 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Tue, 22 Oct 2013 18:42:37 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python Front-end to GCC References: <4012031f-5334-4be8-a673-e0d8c8917fb2@googlegroups.com> <5264dbbe$0$30000$c3e8da3$5496439d@news.astraweb.com> <5265bba8$0$29981$c3e8da3$5496439d@news.astraweb.com> <526668e5$0$29981$c3e8da3$5496439d@news.astraweb.com> <52669852$0$29981$c3e8da3$5496439d@news.astraweb.com> <5266aa80$0$29981$c3e8da3$5496439d@news.astraweb.com> <5266b496$0$29981$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <5266b496$0$29981$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382463758 news.xs4all.nl 15964 [2001:888:2000:d::a6]:43397 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57284 On 22/10/2013 18:23, Steven D'Aprano wrote: > On Tue, 22 Oct 2013 16:53:07 +0000, Frank Miles wrote: > > [snip C code] >> What you're missing is that arr[] is an automatic variable. Put a >> "static" in front of it, or move it outside the function (to become >> global) and you'll see the difference. > > Ah, that makes sense. Thanks to everyone who corrected my > misunderstanding. > > Well, actually, no it doesn't. I wonder why C specifies such behaviour? > Why would you want non-global arrays to be filled with garbage? > Static variables need be initialised only once, whereas auto variables exist on the stack, so they would need to be initialised repeatedly, which was considered too expensive, especially as they would be assigned to before use anyway (hopefully!). Of course, these days, with our much faster CPUs, we're not so bothered, and prefer to allocate on the heap.