What made you choose a python script rather than C++ templates or the C preprocessor?
The simulation was run about 100 times with different parameters. Instead of taking about an hour each they instead took about 12 minutes each, with the only difference being baking in all the parameters as constants and letting GCC do the rest.
edit: oh nm, reread GP...
I think if I had to do something similar again today, any script would output a shell script that used command line macro definitions. That didn't really occur to me at the time.