Skip to content

Faster startup: ezdxf and vtk imported on use - #2097

Open
kimstik wants to merge 2 commits into
CadQuery:masterfrom
kimstik:dxf_vtk
Open

kimstik wants to merge 2 commits into
CadQuery:masterfrom
kimstik:dxf_vtk

Conversation

@kimstik

@kimstik kimstik commented Sep 15, 2026

Copy link
Copy Markdown

import cadquery loaded ezdxf and vtk although most sessions never touch a DXF or a render window. They are now imported by the functions that use them, and a test in a fresh interpreter keeps them out.

Here the import drops from 1.50 to 1.10 seconds - 0.35 for ezdxf with fontTools, 0.15 for vtk - and loads 417 modules instead of 693.

Annotations that name vtk types are forward references now; typing.get_type_hints() on those five functions resolves them once vtk is imported.

@kimstik

kimstik commented Sep 15, 2026

Copy link
Copy Markdown
Author

The rest is OCP: registering 321 packages on import, which costs about a second.
Cadquery needs half of them.
Lazy registration in the generator would recover about 0.5 seconds.
Nanobind would go further I guess.

upd:
lazy registration shows 0.16 sec instead of 0.79 on import OCP
requires basic OCP patching CadQuery/OCP#226

@kimstik
kimstik marked this pull request as ready for review September 15, 2026 16:36
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.76%. Comparing base (cb26a27) to head (87ca6f5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2097   +/-   ##
=======================================
  Coverage   95.76%   95.76%           
=======================================
  Files          30       30           
  Lines        9584     9587    +3     
  Branches     1437     1437           
=======================================
+ Hits         9178     9181    +3     
  Misses        250      250           
  Partials      156      156           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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