<div dir="ltr">There could be a way to change the behavior of "import vtk", e.g.<div><br></div><div>import vtk_settings</div><div>vtk_settings.modules = [ ... ] # whitelist of desired modules?</div><div>import vtk</div><div><br></div><div>The .py files for the VTK modules are actually a bit silly, since they just waste time moving classes from the .pyd module to the .py module. We should build vtkCommonCore.pyd directly (instead of building vtkCommonCorePython.pyd).</div><div><br></div><div> - David</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 8, 2016 at 11:24 AM, Utkarsh Ayachit <span dir="ltr"><<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The problem with that is it will have to be an entirely new package.<br>
Further complication, this package cannot use any of *.py files for<br>
VTK modules or others from the vtk package since as soon as it does<br>
that vtk/__init__.py will import everything. So we'll need to<br>
duplicate all the *.py files too.<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Sep 8, 2016 at 1:14 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br>
> Hi Utkarsh,<br>
><br>
> As usual, I'm a stickler for backwards compatibility and would rather go in<br>
> the other direction,<br>
><br>
> import vtkminimal as vtk<br>
><br>
> - David<br>
><br>
><br>
> On Thu, Sep 8, 2016 at 10:55 AM, Utkarsh Ayachit<br>
> <<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a>> wrote:<br>
>><br>
>> Folks,<br>
>><br>
>> This is in reference to this:<br>
>> <a href="https://gitlab.kitware.com/vtk/vtk/issues/16780" rel="noreferrer" target="_blank">https://gitlab.kitware.com/<wbr>vtk/vtk/issues/16780</a><br>
>><br>
>> `import vtk` is slow because it imports all of VTK. It isn't the best<br>
>> practice, and has no workaround -- given the current implementation<br>
>> where all the modules are imported in vtk/__init__.py itself.<br>
>><br>
>> I have an MR in progress that addresses this issue:<br>
>> <a href="https://gitlab.kitware.com/vtk/vtk/merge_requests/1921" rel="noreferrer" target="_blank">https://gitlab.kitware.com/<wbr>vtk/vtk/merge_requests/1921</a><br>
>><br>
>> This MR does the following:<br>
>> * vtk/__init__.py no longer imports all of VTK.<br>
>> * vtk/all.py is a new module that imports all of VTK.<br>
>><br>
>> This does break old scripts, but provides an easy workaround. For<br>
>> users who want to keep previous behavior, they can simply do the<br>
>> following:<br>
>><br>
>> from vtk import all as vtk<br>
>><br>
>> Thoughts? If this looks reasonable to everyone, I'll update the MR to<br>
>> fix all tests accordingly.<br>
>><br>
>> Thanks<br>
>> Utkarsh<br>
</div></div></blockquote></div><br></div>