python / cpython

The Python programming language
https://www.python.org
Other
63.51k stars 30.42k forks source link

Improve cProfile standard output #79042

Open ef328f3f-19e3-4132-a4cf-afb1d18cc1b4 opened 6 years ago

ef328f3f-19e3-4132-a4cf-afb1d18cc1b4 commented 6 years ago
BPO 34861
Nosy @giampaolo, @boxed, @pablogsal, @DanielNoord
PRs
  • python/cpython#9655
  • python/cpython#13083
  • python/cpython#31929
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['3.8', 'type-feature', 'library'] title = 'Improve cProfile standard output' updated_at = user = 'https://github.com/boxed' ``` bugs.python.org fields: ```python activity = actor = 'pablogsal' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'Anders.Hovm\xc3\xb6ller' dependencies = [] files = [] hgrepos = [] issue_num = 34861 keywords = ['patch'] message_count = 6.0 messages = ['326793', '327147', '327149', '327279', '415856', '416338'] nosy_count = 5.0 nosy_names = ['giampaolo.rodola', 'python-dev', 'Anders.Hovm\xc3\xb6ller', 'pablogsal', 'danielnoord'] pr_nums = ['9655', '13083', '31929'] priority = 'normal' resolution = None stage = 'patch review' status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue34861' versions = ['Python 3.8'] ```

    ef328f3f-19e3-4132-a4cf-afb1d18cc1b4 commented 6 years ago

    The standard output for cProfile when run from a command line is not very useful. It has two main flaws:

    The first makes it very hard to look at the output. The second is very annoying when you get a bunch of __init__.py in the output.

    Suggested solution:

    giampaolo commented 6 years ago

    Can you paste a sample output showing how it looks like pre and post patch?

    ef328f3f-19e3-4132-a4cf-afb1d18cc1b4 commented 6 years ago

    There is an example output on github. Should I paste it here too? I can do it once I get home if you want.

    ef328f3f-19e3-4132-a4cf-afb1d18cc1b4 commented 6 years ago

    Output before this patch:

         3666 function calls (3556 primitive calls) in 0.005 seconds

    Ordered by: standard name

    ncalls tottime percall cumtime percall filename:lineno(function) 2 0.000 0.000 0.002 0.001 \<frozen importlib._bootstrap>:1009(_handle_fromlist) 7 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:103(release) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:143(init) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:147(enter) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:151(exit) 7 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:157(_get_module_lock) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:176(cb) 2 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:194(_lock_unlock_module) 7/1 0.000 0.000 0.003 0.003 \<frozen importlib._bootstrap>:211(_call_with_frames_removed) 53 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:222(_verbose_message) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:307(init) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:311(enter) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:318(exit) 20 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:321(\<genexpr>) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:35(_new_module) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:369(init) 9 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:403(cached) 7 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:416(parent) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:424(has_location) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:504(_init_module_attrs) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:576(module_from_spec) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:58(init) 5/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap>:663(_load_unlocked) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:719(find_spec) 7 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:78(acquire) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:792(find_spec) 15 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:855(enter) 15 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:859(exit) 5 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap>:882(_find_spec) 5/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap>:948(_find_and_load_unlocked) 5/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap>:978(_find_and_load) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1072(init) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1083(create_module) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1091(exec_module) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1233(_path_hooks) 12 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1246(_path_importer_cache) 5 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap_external>:1283(_get_spec) 5 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap_external>:1315(find_spec) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1362(init) 8 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1368(\<genexpr>) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1394(_get_spec) 10 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap_external>:1399(find_spec) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1447(_fill_cache) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1476(\<setcomp>) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1488(path_hook_for_FileFinder) 8 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:282(cache_from_source) 10 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:36(_relax_case) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:412(_get_cached) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:444(_check_name_wrapper) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:481(_classify_pyc) 12 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:51(_r_long) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:514(_validate_timestamp_pyc) 51 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:56(_path_join) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:566(_compile_bytecode) 51 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:58(\<listcomp>) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:617(spec_from_file_location) 8 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:62(_path_split) 23 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:74(_path_stat) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:762(create_module) 4/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap_external>:765(exec_module) 4 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap_external>:836(get_code) 9 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:84(_path_is_mode_type) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:927(init) 8 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:93(_path_isfile) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:952(get_filename) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:957(get_data) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:98(_path_isdir) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:994(pathstats) 100 0.000 0.000 0.001 0.000 \_init.py:183(dumps) 1 0.000 0.000 0.003 0.003 __init.py:97(\<module>) 1 0.000 0.000 0.002 0.002 decoder.py:2(\<module>) 1 0.000 0.000 0.000 0.000 decoder.py:20(JSONDecodeError) 1 0.000 0.000 0.000 0.000 decoder.py:254(JSONDecoder) 1 0.000 0.000 0.000 0.000 decoder.py:284(init) 1 0.000 0.000 0.000 0.000 encoder.py:104(init) 100 0.000 0.000 0.000 0.000 encoder.py:182(encode) 1 0.000 0.000 0.001 0.001 encoder.py:2(\<module>) 100 0.000 0.000 0.000 0.000 encoder.py:204(iterencode) 1 0.000 0.000 0.000 0.000 encoder.py:73(JSONEncoder) 20 0.000 0.000 0.000 0.000 enum.py:275(call) 20 0.000 0.000 0.000 0.000 enum.py:525(new) 23 0.000 0.000 0.000 0.000 enum.py:602(name) 5 0.000 0.000 0.000 0.000 enum.py:607(value) 2 0.000 0.000 0.000 0.000 enum.py:765(missing) 2 0.000 0.000 0.000 0.000 enum.py:772(_create_pseudomember) 4 0.000 0.000 0.000 0.000 enum.py:802(or) 6 0.000 0.000 0.000 0.000 enum.py:808(and) 3 0.000 0.000 0.000 0.000 enum.py:827(_high_bit) 2 0.000 0.000 0.000 0.000 enum.py:844(_decompose) 2 0.000 0.000 0.000 0.000 enum.py:862(\<listcomp>) 5 0.000 0.000 0.000 0.000 enum.py:873(\<lambda>) 5 0.000 0.000 0.000 0.000 enum.py:879(_power_of_two) 6 0.000 0.000 0.001 0.000 re.py:232(compile) 6 0.000 0.000 0.001 0.000 re.py:271(_compile) 1 0.000 0.000 0.001 0.001 scanner.py:2(\<module>) 14 0.000 0.000 0.000 0.000 sre_compile.py:249(_compile_charset) 14 0.000 0.000 0.000 0.000 sre_compile.py:276(_optimize_charset) 4 0.000 0.000 0.000 0.000 sre_compile.py:411(_mk_bitmap) 4 0.000 0.000 0.000 0.000 sre_compile.py:413(\<listcomp>) 9 0.000 0.000 0.000 0.000 sre_compile.py:423(_simple) 13 0.000 0.000 0.000 0.000 sre_compile.py:453(_get_iscased) 8/5 0.000 0.000 0.000 0.000 sre_compile.py:461(_get_literal_prefix) 5 0.000 0.000 0.000 0.000 sre_compile.py:492(_get_charset_prefix) 6 0.000 0.000 0.000 0.000 sre_compile.py:536(_compile_info) 12 0.000 0.000 0.000 0.000 sre_compile.py:595(isstring) 6 0.000 0.000 0.001 0.000 sre_compile.py:598(_code) 12 0.000 0.000 0.000 0.000 sre_compile.py:65(_combine_flags) 25/6 0.000 0.000 0.000 0.000 sre_compile.py:71(_compile) 6 0.000 0.000 0.001 0.000 sre_compile.py:759(compile) 26 0.000 0.000 0.000 0.000 sre_parse.py:111(init) 52 0.000 0.000 0.000 0.000 sre_parse.py:160(len) 123 0.000 0.000 0.000 0.000 sre_parse.py:164(getitem) 10 0.000 0.000 0.000 0.000 sre_parse.py:168(setitem) 25 0.000 0.000 0.000 0.000 sre_parse.py:172(append) 31/12 0.000 0.000 0.000 0.000 sre_parse.py:174(getwidth) 6 0.000 0.000 0.000 0.000 sre_parse.py:224(init) 102 0.000 0.000 0.000 0.000 sre_parse.py:233(next) 71 0.000 0.000 0.000 0.000 sre_parse.py:249(match) 71 0.000 0.000 0.000 0.000 sre_parse.py:254(get) 4 0.000 0.000 0.000 0.000 sre_parse.py:258(getwhile) 38 0.000 0.000 0.000 0.000 sre_parse.py:286(tell) 16 0.000 0.000 0.000 0.000 sre_parse.py:295(_class_escape) 4 0.000 0.000 0.000 0.000 sre_parse.py:355(_escape) 9 0.000 0.000 0.000 0.000 sre_parse.py:432(_uniq) 13/6 0.000 0.000 0.001 0.000 sre_parse.py:441(_parse_sub) 15/6 0.000 0.000 0.001 0.000 sre_parse.py:499(_parse) 6 0.000 0.000 0.000 0.000 sre_parse.py:76(init) 24 0.000 0.000 0.000 0.000 sre_parse.py:81(groups) 6 0.000 0.000 0.000 0.000 sre_parse.py:84(opengroup) 6 0.000 0.000 0.000 0.000 sre_parse.py:927(fix_flags) 6 0.000 0.000 0.001 0.000 sre_parse.py:943(parse) 6 0.000 0.000 0.000 0.000 sre_parse.py:96(closegroup) 1 0.000 0.000 0.005 0.005 stats_test.py:1(\<module>) 28 0.000 0.000 0.000 0.000 types.py:164(get) 2 0.000 0.000 0.000 0.000 {built-in method __new of type object at 0x10402e370} 4 0.000 0.000 0.000 0.000 {built-in method _imp._fix_co_filename} 27 0.000 0.000 0.000 0.000 {built-in method _imp.acquire_lock} 1 0.000 0.000 0.000 0.000 {built-in method _imp.create_dynamic} 1 0.000 0.000 0.000 0.000 {built-in method _imp.exec_dynamic} 2 0.000 0.000 0.000 0.000 {built-in method _imp.is_builtin} 5 0.000 0.000 0.000 0.000 {built-in method _imp.is_frozen} 27 0.000 0.000 0.000 0.000 {built-in method _imp.release_lock} 6 0.000 0.000 0.000 0.000 {built-in method _sre.compile} 10 0.000 0.000 0.000 0.000 {built-in method _thread.allocate_lock} 14 0.000 0.000 0.000 0.000 {built-in method _thread.getident} 3 0.000 0.000 0.000 0.000 {built-in method builtins.\_build_class} 1 0.000 0.000 0.002 0.002 {built-in method builtins.__import} 5 0.000 0.000 0.000 0.000 {built-in method builtins.any} 32 0.000 0.000 0.000 0.000 {built-in method builtins.chr} 5/1 0.000 0.000 0.005 0.005 {built-in method builtins.exec} 30 0.000 0.000 0.000 0.000 {built-in method builtins.getattr} 22 0.000 0.000 0.000 0.000 {built-in method builtins.hasattr} 389 0.000 0.000 0.000 0.000 {built-in method builtins.isinstance} 331/303 0.000 0.000 0.000 0.000 {built-in method builtins.len} 4 0.000 0.000 0.000 0.000 {built-in method builtins.max} 59 0.000 0.000 0.000 0.000 {built-in method builtins.min} 17 0.000 0.000 0.000 0.000 {built-in method builtins.ord} 3 0.000 0.000 0.000 0.000 {built-in method builtins.setattr} 12 0.000 0.000 0.000 0.000 {built-in method from_bytes} 4 0.000 0.000 0.000 0.000 {built-in method marshal.loads} 13 0.000 0.000 0.000 0.000 {built-in method posix.fspath} 2 0.000 0.000 0.000 0.000 {built-in method posix.getcwd} 1 0.000 0.000 0.000 0.000 {built-in method posix.listdir} 23 0.000 0.000 0.000 0.000 {built-in method posix.stat} 312 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} 3 0.000 0.000 0.000 0.000 {method 'bit_length' of 'int' objects} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 6 0.000 0.000 0.000 0.000 {method 'endswith' of 'str' objects} 12 0.000 0.000 0.000 0.000 {method 'extend' of 'list' objects} 48 0.000 0.000 0.000 0.000 {method 'find' of 'bytearray' objects} 33 0.000 0.000 0.000 0.000 {method 'format' of 'str' objects} 38 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects} 1 0.000 0.000 0.000 0.000 {method 'insert' of 'list' objects} 8 0.000 0.000 0.000 0.000 {method 'items' of 'dict' objects} 159 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} 6 0.000 0.000 0.000 0.000 {method 'lower' of 'str' objects} 4 0.000 0.000 0.000 0.000 {method 'read' of '_io.FileIO' objects} 38 0.000 0.000 0.000 0.000 {method 'rpartition' of 'str' objects} 110 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects} 34 0.000 0.000 0.000 0.000 {method 'setdefault' of 'dict' objects} 2 0.000 0.000 0.000 0.000 {method 'sort' of 'list' objects} 2 0.000 0.000 0.000 0.000 {method 'startswith' of 'str' objects} 4 0.000 0.000 0.000 0.000 {method 'translate' of 'bytearray' objects}

    After:

         3666 function calls (3556 primitive calls) in 0.005 seconds

    Ordered by: cumulative time

    ncalls tottime percall cumtime percall filename:lineno(function) 5/1 0.000 0.000 0.005 0.005 {built-in method builtins.exec} 1 0.000 0.000 0.005 0.005 stats_test.py:1(\<module>) 5/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap>:978(_find_and_load) 5/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap>:948(_find_and_load_unlocked) 5/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap>:663(_load_unlocked) 4/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap_external>:765(exec_module) 7/1 0.000 0.000 0.004 0.004 \<frozen importlib._bootstrap>:211(_call_with_frames_removed) 1 0.000 0.000 0.004 0.004 json/init.py:97(\<module>) 1 0.000 0.000 0.002 0.002 decoder.py:2(\<module>) 2 0.000 0.000 0.002 0.001 \<frozen importlib._bootstrap>:1009(_handlefromlist) 1 0.000 0.000 0.002 0.002 {built-in method builtins.\_import} 6 0.000 0.000 0.001 0.000 re.py:232(compile) 6 0.000 0.000 0.001 0.000 re.py:271(_compile) 6 0.000 0.000 0.001 0.000 sre_compile.py:759(compile) 1 0.000 0.000 0.001 0.001 scanner.py:2(\<module>) 6 0.000 0.000 0.001 0.000 sre_parse.py:943(parse) 5 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap>:882(_find_spec) 5 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap_external>:1315(find_spec) 5 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap_external>:1283(_get_spec) 13/6 0.000 0.000 0.001 0.000 sre_parse.py:441(_parse_sub) 4 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap_external>:836(get_code) 15/6 0.000 0.000 0.001 0.000 sre_parse.py:499(_parse) 1 0.000 0.000 0.001 0.001 encoder.py:2(\<module>) 100 0.000 0.000 0.001 0.000 json/init.py:183(dumps) 10 0.000 0.000 0.001 0.000 \<frozen importlib._bootstrap_external>:1399(find_spec) 100 0.000 0.000 0.000 0.000 encoder.py:182(encode) 6 0.000 0.000 0.000 0.000 sre_compile.py:598(_code) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:576(module_from_spec) 25/6 0.000 0.000 0.000 0.000 sre_compile.py:71(_compile) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1083(create_module) 1 0.000 0.000 0.000 0.000 {built-in method _imp.create_dynamic} 100 0.000 0.000 0.000 0.000 encoder.py:204(iterencode) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:566(_compile_bytecode) 23 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:74(_path_stat) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:957(get_data) 23 0.000 0.000 0.000 0.000 {built-in method posix.stat} 4 0.000 0.000 0.000 0.000 {built-in method marshal.loads} 14 0.000 0.000 0.000 0.000 sre_compile.py:276(_optimize_charset) 6 0.000 0.000 0.000 0.000 sre_compile.py:536(_compile_info) 20 0.000 0.000 0.000 0.000 enum.py:275(call) 51 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:56(_path_join) 4 0.000 0.000 0.000 0.000 enum.py:802(or) 12 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1246(_path_importer_cache) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:504(_init_module_attrs) 9 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:84(_path_is_mode_type) 20 0.000 0.000 0.000 0.000 enum.py:525(new) 8 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:93(_path_isfile) 4 0.000 0.000 0.000 0.000 {method 'read' of '_io.FileIO' objects} 31/12 0.000 0.000 0.000 0.000 sre_parse.py:174(getwidth) 2 0.000 0.000 0.000 0.000 enum.py:765(missing) 2 0.000 0.000 0.000 0.000 enum.py:772(_create_pseudomember) 123 0.000 0.000 0.000 0.000 sre_parse.py:164(getitem) 389 0.000 0.000 0.000 0.000 {built-in method builtins.isinstance} 8 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:282(cache_from_source) 71 0.000 0.000 0.000 0.000 sre_parse.py:254(get) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1447(_fill_cache) 102 0.000 0.000 0.000 0.000 sre_parse.py:233(next) 3 0.000 0.000 0.000 0.000 {built-in method builtins.__build_class} 2 0.000 0.000 0.000 0.000 enum.py:844(_decompose) 6 0.000 0.000 0.000 0.000 sre_parse.py:96(closegroup) 9 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:403(cached) 1 0.000 0.000 0.000 0.000 {built-in method posix.listdir} 51 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:58(\<listcomp>) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:147(enter) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:994(path_stats) 2 0.000 0.000 0.000 0.000 {built-in method posix.getcwd} 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:412(_get_cached) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1233(_path_hooks) 331/303 0.000 0.000 0.000 0.000 {built-in method builtins.len} 312 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} 33 0.000 0.000 0.000 0.000 {method 'format' of 'str' objects} 6 0.000 0.000 0.000 0.000 enum.py:808(and) 7 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:157(_get_module_lock) 16 0.000 0.000 0.000 0.000 sre_parse.py:295(_class_escape) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1394(_get_spec) 4 0.000 0.000 0.000 0.000 sre_compile.py:411(_mk_bitmap) 2 0.000 0.000 0.000 0.000 enum.py:862(\<listcomp>) 71 0.000 0.000 0.000 0.000 sre_parse.py:249(match) 6 0.000 0.000 0.000 0.000 sre_parse.py:927(fix_flags) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1488(path_hook_for_FileFinder) 14 0.000 0.000 0.000 0.000 sre_compile.py:249(_compile_charset) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:318(exit) 25 0.000 0.000 0.000 0.000 sre_parse.py:172(append) 9 0.000 0.000 0.000 0.000 sre_compile.py:423(_simple) 159 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} 30 0.000 0.000 0.000 0.000 {built-in method builtins.getattr} 59 0.000 0.000 0.000 0.000 {built-in method builtins.min} 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:151(exit) 53 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:222(_verbose_message) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:481(_classify_pyc) 7 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:78(acquire) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:617(spec_from_file_location) 38 0.000 0.000 0.000 0.000 sre_parse.py:286(tell) 6 0.000 0.000 0.000 0.000 sre_parse.py:224(init) 48 0.000 0.000 0.000 0.000 {method 'find' of 'bytearray' objects} 7 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:103(release) 8/5 0.000 0.000 0.000 0.000 sre_compile.py:461(_get_literal_prefix) 26 0.000 0.000 0.000 0.000 sre_parse.py:111(init) 8 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:62(_path_split) 4 0.000 0.000 0.000 0.000 sre_compile.py:413(\<listcomp>) 38 0.000 0.000 0.000 0.000 {method 'rpartition' of 'str' objects} 22 0.000 0.000 0.000 0.000 {built-in method builtins.hasattr} 2 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:194(_lock_unlock_module) 9 0.000 0.000 0.000 0.000 sre_parse.py:432(_uniq) 6 0.000 0.000 0.000 0.000 {built-in method _sre.compile} 12 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:51(_r_long) 6 0.000 0.000 0.000 0.000 sre_parse.py:84(opengroup) 52 0.000 0.000 0.000 0.000 sre_parse.py:160(len) 38 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects} 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:98(_path_isdir) 28 0.000 0.000 0.000 0.000 types.py:164(get) 5 0.000 0.000 0.000 0.000 sre_compile.py:492(_get_charset_prefix) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:514(_validate_timestamp_pyc) 1 0.000 0.000 0.000 0.000 decoder.py:284(init) 110 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects} 32 0.000 0.000 0.000 0.000 {built-in method builtins.chr} 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1362(init) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:58(init) 4 0.000 0.000 0.000 0.000 sre_parse.py:258(getwhile) 34 0.000 0.000 0.000 0.000 {method 'setdefault' of 'dict' objects} 5 0.000 0.000 0.000 0.000 {built-in method builtins.any} 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:176(cb) 15 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:855(enter) 12 0.000 0.000 0.000 0.000 {method 'extend' of 'list' objects} 12 0.000 0.000 0.000 0.000 sre_compile.py:595(isstring) 24 0.000 0.000 0.000 0.000 sre_parse.py:81(groups) 12 0.000 0.000 0.000 0.000 {built-in method from_bytes} 27 0.000 0.000 0.000 0.000 {built-in method _imp.acquire_lock} 15 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:859(exit) 12 0.000 0.000 0.000 0.000 sre_compile.py:65(_combine_flags) 10 0.000 0.000 0.000 0.000 sre_parse.py:168(setitem) 6 0.000 0.000 0.000 0.000 {method 'endswith' of 'str' objects} 27 0.000 0.000 0.000 0.000 {built-in method _imp.release_lock} 4 0.000 0.000 0.000 0.000 {built-in method _imp._fix_co_filename} 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:35(_new_module) 10 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:36(_relax_case) 20 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:321(\<genexpr>) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:792(find_spec) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:444(_check_name_wrapper) 5 0.000 0.000 0.000 0.000 enum.py:879(_power_of_two) 2 0.000 0.000 0.000 0.000 {method 'sort' of 'list' objects} 5 0.000 0.000 0.000 0.000 {built-in method _imp.is_frozen} 10 0.000 0.000 0.000 0.000 {built-in method _thread.allocate_lock} 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:311(enter) 7 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:416(parent) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1091(exec_module) 6 0.000 0.000 0.000 0.000 sre_parse.py:76(init) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:369(init) 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:719(find_spec) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1476(\<setcomp>) 4 0.000 0.000 0.000 0.000 sre_parse.py:355(_escape) 4 0.000 0.000 0.000 0.000 {method 'translate' of 'bytearray' objects} 17 0.000 0.000 0.000 0.000 {built-in method builtins.ord} 3 0.000 0.000 0.000 0.000 {built-in method builtins.setattr} 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:143(init) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:927(init) 23 0.000 0.000 0.000 0.000 enum.py:602(name) 3 0.000 0.000 0.000 0.000 enum.py:827(_highbit) 2 0.000 0.000 0.000 0.000 {built-in method \_new of type object at 0x10fe1c370} 2 0.000 0.000 0.000 0.000 {method 'startswith' of 'str' objects} 2 0.000 0.000 0.000 0.000 {built-in method _imp.is_builtin} 13 0.000 0.000 0.000 0.000 {built-in method posix.fspath} 14 0.000 0.000 0.000 0.000 {built-in method _thread.get_ident} 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:307(init) 8 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1368(\<genexpr>) 1 0.000 0.000 0.000 0.000 decoder.py:254(JSONDecoder) 5 0.000 0.000 0.000 0.000 enum.py:607(value) 13 0.000 0.000 0.000 0.000 sre_compile.py:453(_get_iscased) 1 0.000 0.000 0.000 0.000 encoder.py:104(init) 1 0.000 0.000 0.000 0.000 encoder.py:73(JSONEncoder) 1 0.000 0.000 0.000 0.000 {method 'insert' of 'list' objects} 3 0.000 0.000 0.000 0.000 {method 'bit_length' of 'int' objects} 8 0.000 0.000 0.000 0.000 {method 'items' of 'dict' objects} 4 0.000 0.000 0.000 0.000 {built-in method builtins.max} 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:762(create_module) 1 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:1072(init) 1 0.000 0.000 0.000 0.000 decoder.py:20(JSONDecodeError) 5 0.000 0.000 0.000 0.000 enum.py:873(\<lambda>) 6 0.000 0.000 0.000 0.000 {method 'lower' of 'str' objects} 1 0.000 0.000 0.000 0.000 {built-in method _imp.exec_dynamic} 5 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap>:424(has_location) 4 0.000 0.000 0.000 0.000 \<frozen importlib._bootstrap_external>:952(get_filename) 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}

    The sorting is easy to see, but the other change is that this line:

      100    0.000    0.000    0.001    0.000 __init__.py:183(dumps)

    ...now looks like this:

      100    0.000    0.000    0.001    0.000 json/__init__.py:183(dumps)
    66d5cb21-1e4a-44f0-854d-760cc76cb6d3 commented 2 years ago

    I have resubmitted the patch that changes the default sorting order in https://github.com/python/cpython/pull/31929 as it was asked to separate that from the original patch by Anders.

    I also added documentation changes that follow from changing the default sorting order.

    pablogsal commented 2 years ago

    New changeset 75eee1d57eb28283a8682a660d9949afc89fd010 by Daniël van Noord in branch 'main': bpo-34861: Make cumtime the default sorting key for cProfile (GH-31929) https://github.com/python/cpython/commit/75eee1d57eb28283a8682a660d9949afc89fd010