Repository navigation
Start faster: import a command group only when it runs - #257
Merged
Merged
Conversation
Every ccli command imported all eight command groups first, and with them WeasyPrint, the extension runtime and Excel support: about 1,800 modules for `ccli --help`. Every command paid that time, and every command failed on machines without Cairo and Pango, although only the PDF reports need them. The root group now knows the built-in groups by name and short help, and imports a group only when it runs. Every output stays exactly the same. One test checks the table against the groups, another that `ccli --help` imports none of them. Third-party plugins load as before. On an M1 Pro with connect-openapi-client 35.0: `ccli --help` 1.7 s -> 1.1 s, `ccli product --help` 1.6 s -> 1.1 s. Most of what remains is the client's import of inflect, which is fixed separately in connect-openapi-client.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
The root
ccligroup knows the eight built-in command groups by name and short help (BUILTIN_GROUPS), and imports a group only when it runs. Third-party plugins load as before.Why
Every command imported all eight groups first: about 1,800 modules for
ccli --help, WeasyPrint included. Every command paid that time, and every command failed on machines without Cairo and Pango, although only the PDF reports need them.Key decisions
--helpdoesn't have to import the groups. A test fails if the table and the groups drift apart, and another checks thatccli --helpimports no group.ccli,ccli --help, the group helps and unknown commands print exactly what master prints (10 cases compared).How it worked before / after
On an M1 Pro, Python 3.10:
ccli --helpccli product --helpLocally, 724 tests pass on Python 3.10 and 3.11. It merges cleanly with the Python 3.12–3.14 PR; together they pass 725.