[Python-Dev] ANSI-fication (was: RE: [Patches] fix simple 64-bit warnings/errorsin signalmodule.c and bufferobject.c)

M.-A. Lemburg mal@lemburg.com
Wed, 07 Jun 2000 12:40:24 +0200


Fredrik Lundh wrote:
> 
> MAL wrote:
> > > (btw, what are all those "register" declarations doing in MAL's
> > > version of unicodeobject.c?  does any modern compiler even
> > > care about that keyword?)
> >
> > "register" helps compilers in situations where normal
> > optimizations don't give satisfying results, e.g. to aid
> > in keeping often used variables or counters in registers
> > rather than on the stack. It can also help with inling
> > functions and can speed up parameter passing.
> 
> Yeah, I know what register is supposed to do.

I know you know, but I find adding some explanations for others
which might not know is good practice.
 
> But common knowledge (at least where I live) is that modern optimizers
> know better than you, and usually ignore "register" altogether if you use
> higher optimization levels... (and if they don't, using "register" is likely to
> make things worse on some platforms).  In other words, "register" should
> not be used in portable code.
> 
> fwiw, a certain Linux kernel hacker seem to agree with me on that one:
> 
>     http://www2.linuxjournal.com/lj-issues/issue17/1138.html
>     ...
>     #define register
>     ...
>     "Gcc, the normal Linux C compiler, understands the register keyword,
>     but the code optimiser is sufficiently good that using register is normally
>     a bad idea."
>     ...

Well, make that "normally not needed": gcc sometimes doesn't inline
functions because it thinks that the function needs parameters to be
on the stack. The register keyword can do wonders here.

Adding "register" is like adding salt & pepper: things usually
taste better than before ;-).

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/