Skip to content

Start faster: import a command group only when it runs - #257

Merged
maxipavlovic merged 1 commit into
masterfrom
fix/load-command-groups-on-demand
Nov 3, 2026
Merged

maxipavlovic merged 1 commit into
masterfrom
fix/load-command-groups-on-demand

Conversation

@maxipavlovic

Copy link
Copy Markdown
Member

What

The root ccli group 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

  • The short helps are listed in a table, so --help doesn't have to import the groups. A test fails if the table and the groups drift apart, and another checks that ccli --help imports no group.
  • The output doesn't change: 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:

master this PR with cloudblue/connect-python-openapi-client#90 too
ccli --help 1.6 s 1.1 s 0.17 s
ccli product --help 1.6 s 1.1 s, no Cairo or Pango needed 0.23 s

Locally, 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.

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.
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

@arnaugiralt arnaugiralt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pcaro pcaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@maxipavlovic
maxipavlovic merged commit da2b016 into master Nov 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants