So I have a big project with many modules in it, and I want to run some profiling on it. I have a profile module that basically just provides a decorator that I can add to a function to profile it when it's called.

The problem is, I'll have to import that module into the dozens of modules that I have. This is fine I guess, but I can't push the code with the profiling modules imported or the decorator on the functions to version control. This means every time I import/export, I have to add/remove all my profiling code.

Is there any kind of system to manage this adding/removing of profiling code without manually importing/deleting the modules in every module of my project? We use mercurial, but I can't really mess with mercurial settings or make a branch.