Issue716587
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2003-04-07 06:56 by gregfortune, last changed 2022-04-10 16:08 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
profile.diff | gregfortune, 2003-04-07 14:36 | Diff between Python 2.2 profile.py and my change |
Messages (8) | |||
---|---|---|---|
msg15387 - (view) | Author: Greg Fortune (gregfortune) | Date: 2003-04-07 06:56 | |
When profile.run() is executed, it assumes that the local and global namespace should be determined from the locals and globals for __main__. In the case of an embedded interpreter, this is an annoying assumption. For instance, I have a PyQt program that has an embedded interpreter running as a "debug" console and need to profile a little segement of misbehaving code. With direct access to all the gui interactively, it seemed like a simple task of profiling a function call on one of my gui elements, but the namespace in the interpreter is very different from that of the main application. A simple fix is to allow profile.run to be executed with an optional dict so the user can give their own namespace. A diff -u is attached which accomplishes this. Note that this problem appears in the current Python CVS on sourceforge, but exists at least as early as Python 2.2. |
|||
msg15388 - (view) | Author: Michael Hudson (mwh) | Date: 2003-04-07 12:31 | |
Logged In: YES user_id=6656 There's no uploaded file! You have to check the checkbox labeled "Check to Upload & Attach File" when you upload a file. Please try again. (This is a SourceForge annoyance that we can do nothing about. :-( ) |
|||
msg15389 - (view) | Author: Greg Fortune (gregfortune) | Date: 2003-04-07 14:36 | |
Logged In: YES user_id=155459 Doh, sorry about that. Guess I should actually check it after I submit... |
|||
msg15390 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2003-07-09 06:18 | |
Logged In: YES user_id=80475 This seems like a reasonable request. The use case is uncommon but I don't like having __main__ hardwired in the code. What do you think? If you want the change, should it be put into Py2.3? |
|||
msg15391 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2004-03-20 23:01 | |
Logged In: YES user_id=6380 I don't see the issue. Why can't you use prof = profile.Profile() prof.runctx(cmd, mydict, mydict) ??? |
|||
msg15392 - (view) | Author: Greg Fortune (gregfortune) | Date: 2004-03-20 23:40 | |
Logged In: YES user_id=155459 Partially because the only entry point to the profiler mentioned in the documentation is profile.run. If the Profile class were documented, it would be a little more obvious how one would work around the limitation. Secondly, the assumption that __main__ is always the desired namespace seems limiting and arbitrary. Anybody wanting to profile inside an embedded interpreter is going to have to dig through the code the same way I did to identify the problem. Could the namespace be magically determined based on the function that is being profiled? If so, that is probably an even better solution as it becomes a none issue. At the very least, profile.run should grab the namespace from the current interpreter rather than __main__ and that's probably better than my initial proposal anyway. So, it's not a matter of being impossible to work around... It's just not an ideal interface yet. |
|||
msg15393 - (view) | Author: Neil Schemenauer (nascheme) * | Date: 2004-03-21 13:41 | |
Logged In: YES user_id=35752 I always use 'run_call'. You can easily make a closure to capture any bindings you want. Usually it is not necessary. run_call should be available as a global function and it should be documented, IMHO. |
|||
msg15394 - (view) | Author: Nick Bastin (nbastin) * | Date: 2004-03-22 20:25 | |
Logged In: YES user_id=430343 Added profile.runctx function which is a simple cover of profile.Profile.runctx Fixed in: libprofile.tex 1.44 profile.py 1.52 test_profile.py 1.3 test/output/test_profile 1.2 Misc/NEWS 1.958 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:08:02 | admin | set | github: 38268 |
2003-04-07 06:56:15 | gregfortune | create |