[issue17130] Add runcall() function to profile.py and cProfile.py
Changes by Éric Araujo mer...@netwok.org: -- resolution: - duplicate stage: needs patch - committed/rejected status: open - closed superseder: - Add a profile decorator to profile and cProfile ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Björn Skoglund added the comment: Hello, first patch, be kind. I opted for option 2 so there is top keywords filename_ and sort_ filtered out before calling func. The test in test_profile seems to call runctx but runcall and run are never tested. Not sure if this is missing or intended. -- keywords: +patch nosy: +bjorns Added file: http://bugs.python.org/file29180/issue17130.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Giampaolo Rodola' added the comment: I already posted a patch in issue 9285. Maybe we should close this one as a duplicate. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Björn Skoglund added the comment: Look at that. Sorry, totally missed it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Guido van Rossum added the comment: Antoine, what about the decorator? I've come across a few use cases. --Guido van Rossum (sent from Android phone) On Feb 10, 2013 10:14 AM, Antoine Pitrou rep...@bugs.python.org wrote: Antoine Pitrou added the comment: +1 for runcall() and the context manager. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Giampaolo Rodola' added the comment: See issue 9285 in which I wrote a decorator for profile/cProfile. That can be modified to work both as a decorator or a context manager by using contextlib.contextmanager. Shall I continue in issue 9285 and rewrite that patch? -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Guido van Rossum added the comment: Sure, I will comment on that issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Antoine Pitrou added the comment: Antoine, what about the decorator? I've come across a few use cases. I don't know, I'm thinking that there should be one obvious way to do it :-) By that I mean that the context manager is more generic than the decorator. Or do you want to decorate functions from an external library? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Guido van Rossum added the comment: If I quickly want to profile one function, with the decorator I have to insert a with-statement in its body and mess with the indentation of the entire body. With a decorator it's just a one-line insertion. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Antoine Pitrou added the comment: Ah, fair enough. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Giampaolo Rodola' added the comment: As for runcall() we haven't the ability to freely support kwargs *and* filename. I see two possibilities. Kill kwargs, as such: +def runcall(func, *args, filename=None, sort=-1): +Run func(*args) under profiler, optionally saving results in +filename. + ...or make 'filename_' and 'sort_' two special name kwargs to be used as in: runcall(fun, foo=1, bar=2, filename_='...') Also, there might be some value in adding 'strip_dirs' argument to those functions (run/runctx/runcall). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Antoine Pitrou added the comment: +1 for runcall() and the context manager. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Changes by Éric Araujo mer...@netwok.org: -- keywords: +easy nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
Guido van Rossum added the comment: While we're on profile convenience features, how about adding two context managers: - one that just profiles a block and prints the profile (or dumps the data to a file) - one that takes a Profile instance and enables profiling to that instance E.g. (1) with cProfile.runblock([file]): your code here or (2) p = cProfile.Profile() with p: your code here Also a decorator corresponding to (1): @cProfile.runfunc([filename]) def myfunc(args): stuff -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17130] Add runcall() function to profile.py and cProfile.py
New submission from Guido van Rossum: The profile module exports convenience functions for run() and runctx(), which wrap the corresponding methods of the Profile object. But perhaps the most useful method, runcall(), is not wrapped. :-( -- messages: 181403 nosy: gvanrossum priority: normal severity: normal stage: needs patch status: open title: Add runcall() function to profile.py and cProfile.py type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com