Skip to content

fix: use lazy imports to speed up module import time (#476)#501

Open
manmohan-shaw-okta wants to merge 1 commit intomasterfrom
fix/lazy-module-imports
Open

fix: use lazy imports to speed up module import time (#476)#501
manmohan-shaw-okta wants to merge 1 commit intomasterfrom
fix/lazy-module-imports

Conversation

@manmohan-shaw-okta
Copy link

Replace eager imports in okta/init.py, okta/api/init.py, and okta/models/init.py with lazy-loading using PEP 562 module getattr.

Previously, 'import okta' eagerly loaded ~1900 classes (116 API classes + 1773 model classes), each pulling in pydantic, typing, etc. This caused import times of 2-5 seconds.

With lazy loading, modules are only imported when their attributes are first accessed, reducing 'import okta' time from ~2s to ~0.007s (~280x faster).

Replace eager imports in okta/__init__.py, okta/api/__init__.py, and
okta/models/__init__.py with lazy-loading using PEP 562 module __getattr__.

Previously, 'import okta' eagerly loaded ~1900 classes (116 API classes +
1773 model classes), each pulling in pydantic, typing, etc. This caused
import times of 2-5 seconds.

With lazy loading, modules are only imported when their attributes are first
accessed, reducing 'import okta' time from ~2s to ~0.007s (~280x faster).
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.

1 participant