[Python-Dev] ANSI-fication (was: RE: [Patches] fix simple 64-bit warnings/errorsin signalmodule.c and bufferobject.c)
Fredrik Lundh
fredrik@pythonware.com
Wed, 7 Jun 2000 12:24:46 +0200
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?)
>=20
> "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.
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."
...
(If it's good enough for Alan Cox etc).
But never mind. I doubt that removing them would matter on any con-
temporary platform, but on the other hand, keeping them in there won't
hurt much either. It just makes the source code a little bit more ver-
bose than it has to be...
</F>