Skip to content

Defer the psutil import until it is actually needed - #1551

Merged
minrk merged 1 commit into
ipython:mainfrom
Carreau:lazy-psutil
Sep 3, 2026
Merged

Defer the psutil import until it is actually needed#1551
minrk merged 1 commit into
ipython:mainfrom
Carreau:lazy-psutil

Conversation

@Carreau

@Carreau Carreau commented Sep 3, 2026

Copy link
Copy Markdown
Member

psutil is optional and its import is not cheap, yet it was paid for on every kernel startup even though most sessions never ask for usage information or need to enumerate child processes.

It is now imported through _get_psutil(), which caches the (possibly None) result on first use.

psutil is optional and its import is not cheap, yet it was paid for on
every kernel startup even though most sessions never ask for usage
information or need to enumerate child processes.

It is now imported through `_get_psutil()`, which caches the (possibly
None) result on first use.
@minrk
minrk merged commit 7c9f9b4 into ipython:main Sep 3, 2026
41 of 43 checks passed
@Carreau

Carreau commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants