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 2009年02月20日 13:10 by hagen, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| ceval.patch | hagen, 2009年02月21日 13:45 | |||
| issue5330.patch | pitrou, 2009年05月30日 21:00 | |||
| Messages (4) | |||
|---|---|---|---|
| msg82530 - (view) | Author: Hagen Fürstenau (hagen) | Date: 2009年02月20日 13:10 | |
A C function or method call without keyword arguments gets reported by
the profiler as expected (in the line with "{method 'sort' of 'list'
object}"):
>>> cProfile.run("[].sort()")
4 function calls in 0.000 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 {built-in method exec}
1 0.000 0.000 0.000 0.000 {method 'disable' of
'_lsprof.Profiler' objects}
1 0.000 0.000 0.000 0.000 {method 'sort' of 'list'
objects}
However, once a keyword argument is given, the relevant line is missing:
>>> cProfile.run("[].sort(reverse=True)")
3 function calls in 0.000 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 {built-in method exec}
1 0.000 0.000 0.000 0.000 {method 'disable' of
'_lsprof.Profiler' objects}
This happens with profile and cProfile in 2.6 and 3.0.
|
|||
| msg82566 - (view) | Author: Hagen Fürstenau (hagen) | Date: 2009年02月21日 13:45 | |
I found the reason for this problem: C function calls with keyword
arguments follow a different path than those without keywords in the
function "call_function" of ceval.c. They end up being handled by
"do_call", but there the call is not wrapped by C_TRACE, so a profiler
function registered through sys.setprofile() doesn't see such calls.
The same problem occurs in "ext_do_call", which gets called in the
handling of the opcodes CALL_FUNCTION_VAR and CALL_FUNCTION_KW, causing
omission of a function call like
>>> [].sort(**{'reverse':True})
from the profiler report.
The attached patch solves the problem, but I don't know if it's the best
solution. Handling calls with keyword arguments at the beginning of
"call_function" seems to have bigger performance drawbacks though.
|
|||
| msg88580 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年05月30日 21:00 | |
Updated patch, with test. |
|||
| msg88583 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年05月30日 21:44 | |
Committed in r73064, r73065, r73066, r73067. Thanks! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:45 | admin | set | github: 49580 |
| 2009年05月30日 21:44:39 | pitrou | set | status: open -> closed resolution: fixed messages: + msg88583 |
| 2009年05月30日 21:00:10 | pitrou | set | files:
+ issue5330.patch nosy: + pitrou messages: + msg88580 |
| 2009年04月15日 10:28:17 | pitrou | set | stage: patch review versions: + Python 3.1, Python 2.7 |
| 2009年04月05日 17:36:02 | georg.brandl | set | assignee: nbastin nosy: + nbastin |
| 2009年04月05日 17:35:57 | georg.brandl | link | issue1229680 superseder |
| 2009年04月05日 15:30:24 | georg.brandl | set | priority: critical |
| 2009年02月21日 13:45:50 | hagen | set | files:
+ ceval.patch keywords: + patch messages: + msg82566 |
| 2009年02月20日 13:10:18 | hagen | create | |