Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'static': 0.04; 'subject:Python': 0.06; 'variables': 0.07; '22,': 0.09; 'arrays': 0.09; 'differing': 0.09; 'means,': 0.09; 'undefined': 0.09; 'cc:addr:python-list': 0.11; 'ah,': 0.16; 'heap': 0.16; 'lexical': 0.16; 'literals.': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'variable.': 0.16; 'wrote:': 0.18; 'stack': 0.19; 'cc:addr:python.org': 0.22; 'exists': 0.24; 'specifies': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'array': 0.29; 'wonder': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; '(which': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject:end': 0.31; 'file': 0.32; 'front': 0.32; 'url:python': 0.33; 'everyone': 0.33; 'cases': 0.33; 'sources': 0.33; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'performance': 0.37; 'skip:& 10': 0.38; 'filled': 0.38; 'issue': 0.38; 'url:mail': 0.40; 'free': 0.61; "you're": 0.61; "you'll": 0.62; 'such': 0.63; 'become': 0.64; 'more': 0.64; 'effectively': 0.66; 'due': 0.66; 'frank': 0.68; 'behavior': 0.77; 'actually,': 0.84; 'difference.': 0.84; 'thing,': 0.91; '2013': 0.98 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=ble4XWJ7UzOhiWRn5EX9KlfdjmcVAunpi8Jv33sGmfk=; b=g0J9f3+tIJR3UwZv+/pnvW4VDulPYi7TkArxwUVYk4pl9nedbg5PJY0BT03++8suA/ CHZd7I+fWUsu3JT/yfACOeTs1+KCBPVKLgLxxKdi9NtL2KxHlazN+AJrTBwhu710nLku ObQtUikm3qIRu/fro3deEXF5lL9U1PDruYDllw2a2u0taSrnMUSNhK5fIgICfxRrGIRQ aLdZ/nAwD6/xOopIpuH14/NhbtDcdH7IxtoQLrmzrUADAubHkzg2M9Mu33DgU4YQizmY 3jw3p/Qv2MncFwff/l4whFBh6m8irrnYFudi/nWKXzF+6hRE/riHtk9BoeD9ROol4C3B CDcw== X-Gm-Message-State: ALoCoQkpl2OL0adtaJrLAtNy5V0DWrDSsrhfaBx/DXLisX52A12aCF57SB5DlGrmCxtoTpAhOEcP X-Received: by 10.60.58.10 with SMTP id m10mr2209590oeq.61.1382463371615; Tue, 22 Oct 2013 10:36:11 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <5266b496$0$29981$c3e8da3$5496439d@news.astraweb.com> 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> From: Chris Kaynor Date: Tue, 22 Oct 2013 10:35:51 -0700 Subject: Re: Python Front-end to GCC To: "Steven D'Aprano" Content-Type: multipart/alternative; boundary=089e01538bc42e370704e957d61e Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 88 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382463375 news.xs4all.nl 15935 [2001:888:2000:d::a6]:35379 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57281 --089e01538bc42e370704e957d61e Content-Type: text/plain; charset=ISO-8859-1 On Tue, Oct 22, 2013 at 10:23 AM, Steven D'Aprano < steve+comp.lang.python@pearwood.info> 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? > > Its a performance benefit, for cases where you are going to fill the array from other means, such as from a file or other sources such as literals. The global and static variables are effectively free to zero due to standard OS behaviours. The issue is actually more general than arrays, as the same behavior exists for all the types in C. Stack and heap variables have undefined value when initialized, while global and static variables (which are really the same thing, but with differing lexical scopes) are zero-filled. > > -- > Steven > -- > https://mail.python.org/mailman/listinfo/python-list > --089e01538bc42e370704e957d61e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Tue, Oct 22, 2013 at 10:23 A= M, Steven D'Aprano <steve+comp.lang.python@pearwood= .info> wrote:
On Tue, 22 Oct 20= 13 16:53:07 +0000, Frank Miles wrote:

[snip C code]
> What you're missing is that arr[] is an automati= c variable. =A0Put 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?

<= br>
Its a performance benefit, for cases where you are going to f= ill the array from other means, such as from a file or other sources such a= s literals. The global and static variables are effectively free to zero du= e to standard OS behaviours.

The issue is actually more general than arrays, as the = same behavior exists for all the types in C. Stack and heap variables have = undefined value when initialized, while global and static variables (which = are really the same thing, but with differing lexical scopes) are zero-fill= ed.
=A0

--089e01538bc42e370704e957d61e--