Open
Description
Description of the problem, including code/CLI snippet
$ time gitlab 2>/dev/null
real 0m0,675s
user 0m0,619s
sys 0m0,056s
Expected Behavior
Startup time should not be noticeable.
Actual Behavior
0.675s is spent for nothing.
Specifications
- python-gitlab version: 2.9.0
- API version you are using (v3/v4): v4
Below is the profiling result:
$ python3 -m cProfile -s cumtime <(echo 'from gitlab.cli import main; main()') 2>&/dev/null |head -n 15
1012694 function calls (1005974 primitive calls) in 0.871 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
274/1 0.002 0.000 0.871 0.871 {built-in method builtins.exec}
1 0.000 0.000 0.871 0.871 15:1(<module>)
1 0.000 0.000 0.708 0.708 cli.py:192(main)
1 0.000 0.000 0.703 0.703 cli.py:158(_get_parser)
1 0.001 0.001 0.667 0.667 cli.py:307(extend_parser)
169 0.009 0.000 0.516 0.003 cli.py:174(_populate_sub_parser_by_class)
816 0.003 0.000 0.427 0.001 argparse.py:1121(add_parser)
818 0.008 0.000 0.425 0.001 argparse.py:1650(__init__)
2796 0.002 0.000 0.347 0.000 gettext.py:750(gettext)
2796 0.005 0.000 0.345 0.000 gettext.py:675(dgettext)
It seems that too much subparsers have been added. I would suggest:
- to get the subcommand name before populating subparsers for it
- to show only the "toplevel" subcommands in the help message (
current-user
,group
,project
,user
, etc.) unless the user demands otherwise