Can you move the namedtuple declaration to the module scope? namedtuple does some weird class-generation stuff (essentially an exec over a string template). I'd rather only do that sort of thing once.