#define (from C) in Python

Diez B. Roggisch deets at nospam.web.de
Thu Nov 12 17:45:15 CET 2009


Santiago Romero schrieb:
> Is there a Python version of C's language #define statements?
> 
> Example:
> 
> #define ReadMem( (x) )    memory[ (x) ]
> 
>  Instead of using a function, when you call to ReadMem(), the code is
> INCLUDED, (no function is called, the "compiler" just substitues the
> ReadMem( expression ) with memory[ (expression) ] .
> 
>  I want to avoid function calls to speed up a program by sacrifizing
> the resulting size ...
> 
>  Is that possible?

Not without taking the extra step of a ... preprocessor. As C does.

Diez



More information about the Python-list mailing list