[vtk-developers] Speeding up `import vtk`

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Thu Sep 8 12:55:04 EDT 2016


Folks,

This is in reference to this: https://gitlab.kitware.com/vtk/vtk/issues/16780

`import vtk` is slow because it imports all of VTK. It isn't the best
practice, and has no workaround -- given the current implementation
where all the modules are imported in vtk/__init__.py itself.

I have an MR in progress that addresses this issue:
https://gitlab.kitware.com/vtk/vtk/merge_requests/1921

This MR does the following:
* vtk/__init__.py no longer imports all of VTK.
* vtk/all.py is a new module that imports all of VTK.

This does break old scripts, but provides an easy workaround. For
users who want to keep previous behavior, they can simply do the
following:

   from vtk import all as vtk

Thoughts? If this looks reasonable to everyone, I'll update the MR to
fix all tests accordingly.

Thanks
Utkarsh


More information about the vtk-developers mailing list