Perf: lazy-load heavy modules to speed up 'import datajoint' on macOS#1325
Perf: lazy-load heavy modules to speed up 'import datajoint' on macOS#1325sarpit2907 wants to merge 5 commits intodatajoint:masterfrom
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Hi @sarpit2907, thank you for working on this optimization! We already have PR #1321 open that addresses the same issue (#1220). The approaches differ slightly: Your approach (PR #1325):
PR #1321 approach:
The Since #1321 is already in review and takes a more conservative approach, we'll likely proceed with that one. However, your contribution is appreciated and the timing analysis you provided is valuable! Feel free to review #1321 and provide feedback if you see improvements we could incorporate. |
|
Thanks for the detailed feedback @dimitri-yatsenko — that makes sense. I agree that the getattr-based approach in #1321 is more conservative and better aligned with the existing import structure. I’m glad the profiling and timing analysis was useful. I’ll take a closer look at #1321 and share feedback or suggestions there if I spot anything that could be improved. Thanks again for the review! |
|
Thank you for the contribution! We've decided to go in a different direction for this feature. We appreciate your effort and time spent on this PR. |
This PR addresses #1220 by reducing eager imports during 'import datajoint'.
Problem
On macOS, importing DataJoint was slow (~13s), primarily due to eager imports of:
Solution
__getattr__indatajoint/__init__.pyResults (macOS, Python 3.11)
Remaining import cost is dominated by core components (connection, numpy), which are expected.
Notes
This change does not alter behavior and only affects import-time performance.