Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit4.readnews.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Python Front-end to GCC Date: Tue, 22 Oct 2013 15:36:38 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 36 Message-ID: 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> NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1382456198 11918 64.122.56.22 (22 Oct 2013 15:36:38 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 22 Oct 2013 15:36:38 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:57265 On 2013-10-22, Dave Angel wrote: > On 22/10/2013 08:00, Steven D'Aprano wrote: >> [quote] >> C does not require you to set static global arrays to ?0?, so the >> for loop in the main function can go... >> >> Wait a minute... Haskell, I'm pretty sure, zeroes memory. C doesn't. So > > Static int variables are in fact zeroed. However, most C compilers > do it by putting four bytes (or whatever) into the image of the > executable so it has no runtime cost. No, that's not how gcc works (nor is it how any other C compiler I've ever seen works). Static variables get located in a "bss" section[1], which is zeroed out at run-time by startup code that gets executed before main() is called. The ELF executable contains headers that describe the size/location of bss section, but the object file contains no actual _data_. [1] IIRC, the name "bss" is a historical hold-over from the PDP-11 assembler directive that is used to declare a section of memory that is to be filled with zeros. Not all compilers use that section name, but they all use the same mechanism. > int myvar = 34 * 768; > > it'll put the product directly in the executable image, and no > runtime code is generated. That is true. -- Grant Edwards grant.b.edwards Yow! My EARS are GONE!! at gmail.com