<div dir="ltr">Hi Ben,<div><br></div><div>I like Matt's comments on lazy-loading, it would allow us to keep backwards compatibility while speeding up load times. Python provides a way to override getattr() for modules:</div><div><a href="https://stackoverflow.com/questions/2447353/getattr-on-a-module">https://stackoverflow.com/questions/2447353/getattr-on-a-module</a><br></div><div><br></div><div> - David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 19, 2017 at 8:29 AM, Ben Boeckel <span dir="ltr"><<a href="mailto:ben.boeckel@kitware.com" target="_blank">ben.boeckel@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[ Yes, this is a necro on this thread, but I'd like to see this happen. ]<br>
<span class=""><br>
On Thu, Sep 08, 2016 at 11:14:21 -0600, David Gobbi wrote:<br>
> As usual, I'm a stickler for backwards compatibility and would rather go in<br>
> the other direction,<br>
<br>
</span>How about fixing `vtk` for VTK9? I don't like having it be a separate<br>
module because that means we have to ship things twice and the only<br>
difference is the `__init__.py` file.<br>
<br>
Currently `import vtk` (the obvious thing to do) is basically like doing<br>
a `find_package(VTK REQUIRED)` that doesn't support `COMPONENTS`. You<br>
get everything built, but you also have no idea if what you need is<br>
actually present until you get your `AttributeError`.<br>
<br>
I'd rather see scripts explicitly request `vtk.FiltersParallel` (or<br>
similar) if they need it rather than just hoping it dumped the right<br>
things into the global namespace. If we want to keep having this<br>
pattern, ParaView's `paraview.simple` module provides everything needed<br>
to "hit the ground running" (though I don't see it as a long-term<br>
maintainable way to use VTK or ParaView via Python). VTK could also have<br>
`vtk.simple` which does this. The problem with having it at the root<br>
level is that it denies any advanced usage of the module which does<br>
request exactly what is required.<br>
<br>
With all the other big changes coming in VTK9, I think it would be a<br>
good time to tackle this.<br>
<br>
--Ben<br>
<br>
P.S. For those curious, this came up because we recently had one module<br>
have more "load commands" than the loader on macOS supports<br>
(vtkPVAnimation) which triggered an `ImportError`. Because `import vtk`<br>
loads all modules, this meant that any loading of `import vtk` was<br>
broken just because this one was, even tests which don't care about it<br>
at all.<br>
</blockquote></div><br></div>