[vtk-developers] Speeding up `import vtk`

David Gobbi david.gobbi at gmail.com
Thu Sep 8 13:14:21 EDT 2016


Hi Utkarsh,

As usual, I'm a stickler for backwards compatibility and would rather go in
the other direction,

  import vtkminimal as vtk

 - David

On Thu, Sep 8, 2016 at 10:55 AM, Utkarsh Ayachit <
utkarsh.ayachit at kitware.com> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160908/7f0ffafd/attachment.html>


More information about the vtk-developers mailing list