Issue 17197: c/profile refactoring - Python tracker (original) (raw)

Created on 2013-02-12 22:40 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
profile-refactoring.diff giampaolo.rodola,2013-02-12 22:40 review
profile-refactoring.diff giampaolo.rodola,2013-02-17 18:50 review
Messages (6)
msg181980 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2013-02-12 22:40
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?
msg182008 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-02-13 10:09
The patch doesn't look right to me. If you import cProfile, profile will always invoke the cProfile profiler.
msg182010 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2013-02-13 10:10
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
msg182026 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-02-13 12:08
> 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.
msg182281 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2013-02-17 18:50
Of course you're right. I didn't realize that. How about this (in attachment)?
msg182928 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-02-25 10:38
New changeset 422169310b7c by Giampaolo Rodola' in branch 'default': Fix #17197: profile/cProfile modules refactored so that code of run() and runctx() utility functions is not duplicated in both modules. http://hg.python.org/cpython/rev/422169310b7c
History
Date User Action Args
2022-04-11 14:57:41 admin set github: 61399
2020-11-18 19:17:46 iritkatriel link issue12684 superseder
2013-02-25 10:43:23 giampaolo.rodola set status: open -> closedassignee: giampaolo.rodolaresolution: fixed
2013-02-25 10:38:38 python-dev set nosy: + python-devmessages: +
2013-02-17 18:50:04 giampaolo.rodola set files: + profile-refactoring.diffkeywords: + patchmessages: +
2013-02-13 12:08:04 pitrou set messages: +
2013-02-13 10:10:58 giampaolo.rodola set messages: +
2013-02-13 10:09:09 pitrou set messages: +
2013-02-12 22:40:35 giampaolo.rodola set keywords: + easy, - patchcomponents: + Library (Lib)versions: + Python 3.4
2013-02-12 22:40:09 giampaolo.rodola create