#define (from C) in Python

Bearophile bearophileHUGS at lycos.com
Fri Nov 13 07:58:11 EST 2009


Santiago Romero:

>Obviously, I prefer to write well structured code but I had to sacrifize SIZE by SPEED<

In C99 you have "inline" (and gcc/gcc-llvm usually inline small
functions anyway) that helps avoid many macros.


>  Now I'm porting the emulator to a scripted language, so I need
> even more previous design ideas before starting to code, so that
> I can achieve (I hope I'll be able to do it with this group's help)
> 100% cpu speed in an standard desktop PC.

The tecniques needed to speed up Python code are very different from
the ones you use in C. You may need a lot of time to learn Python
performance tricks. Psyco helps a lot.


>  Well, I don't agree with that, "constants" and "macros" wouldn't
> hurt python, when using them in the right situations.

I miss true constants in Python, but it may be impossible to add them
to this language, because of how it uses references. In Python you
rely on convention, writing their names ALL_UPPERCASE.

Bye,
bearophile



More information about the Python-list mailing list