profile and cProfile modules define the same utility functions (run() and runctx()) which use the same code except the profiler class. Considering that we're going to add 2 new utility functions (runcall() and runblock(), see and ) I think we should refactor the code in order to avoid this code duplication. Patch in attachment does that. The approach I came up with looks a bit hackish though so I'd like to get some feedback. Is it acceptable?
No, it's the other way around. It's from cProfile which I import profile. diff --git a/Lib/cProfile.py b/Lib/cProfile.py --- a/Lib/cProfile.py +++ b/Lib/cProfile.py ... +import profile as _pyprofile
> No, it's the other way around. It's from cProfile which I import > profile. > > diff --git a/Lib/cProfile.py b/Lib/cProfile.py > --- a/Lib/cProfile.py > +++ b/Lib/cProfile.py > ... > +import profile as _pyprofile That's exactly what I'm saying. Once you import cProfile, the attributes on the profile functions are overriden. Either way, a module shouldn't mutate another module's functions.