Program startup time was really slow. After inspecting it with -Ximporttime it turned out to be pulling in a lot of unnecessary packages from pkg_resources responsible only for debug functionality.
Solution: reduce the scope of the debug import.
Note that this type of optimization is more of a hack than a solution, but considering it significantly improves startup time for the 99%+ of use cases it is worth implementing.
Before the patch:
$ time python3.10 -m rivalcfg --help > /dev/null
real 0m0,156s
user 0m0,125s
sys 0m0,023s
$ time python3.10 -m rivalcfg -s 800
real 0m0,260s
user 0m0,129s
sys 0m0,021s
After the patch:
$ time python3.10 -m rivalcfg --help > /dev/null
real 0m0,069s
user 0m0,050s
sys 0m0,011s
$ time python3.10 -m rivalcfg -s 800
real 0m0,185s
user 0m0,060s
sys 0m0,015s
Program startup time was really slow. After inspecting it with
-Ximporttime
it turned out to be pulling in a lot of unnecessary packages frompkg_resources
responsible only for debug functionality.Solution: reduce the scope of the debug import.
Note that this type of optimization is more of a hack than a solution, but considering it significantly improves startup time for the 99%+ of use cases it is worth implementing.
Before the patch:
After the patch: