When I want to use valgrind to check for leaks in a Python program (or
test suite), I generally want pymalloc disabled. When not running
valgrind I generally want it enabled.
Attached is a patch that automatically bypasses the pymalloc code when
running under valgrind but leaves it enabled overwise.
It is controlled by a WITH_VALGRIND #define, but I haven't updated the
configure script to allow turning it on. I also haven't done much in
the way of profiling to see what the overhead is when not running under
valgrind.