I recently added lazyloader from tensorflow to freecad. The pull was merged so it's available on master. If your workbench is importing a module that is a little slow, you can defer loading until first usage. This really helps with workbench loading times. Here's how you use it:
The first argument must be a module, is this right? The third argument seems to be whatever object you are importing, that is, the module itself, a class, or variable, or what?
The first variable is the package or module name, the second variable is the parents globals, the third variable is the package or package and submodule. You can't pull in functions though, it has to be a package or module. I actually haven't tried it the way you called it, with module.whatever as the first variable, the examples had it how I showed it. You'd have to try to see if it works that way.
etrombly wrote: ↑Wed Apr 15, 2020 5:37 pm
The first variable is the package or module name, the second variable is the parents globals, the third variable is the package or package and submodule. You can't pull in functions though, it has to be a package or module. I actually haven't tried it the way you called it, with module.whatever as the first variable, the examples had it how I showed it. You'd have to try to see if it works that way.
Can we get some documentation on this neat new functionality ?
Kunda1 wrote: ↑Sun Apr 26, 2020 4:32 pm
Can we get some documentation on this neat new functionality ?
I'm not sure what sort of additional documentation you need. The usage is pretty much what is described in the first post. And this is already documented in the source code, in src/3rdParty/lazy_loader/__init__.py
Essentially we just need to change the first and third arguments and that's all there is to it to defer the import of that particular module.
vocx wrote: ↑Tue Apr 28, 2020 4:37 am
I'm not sure what sort of additional documentation you need. The usage is pretty much what is described in the first post. And this is already documented in the source code, in src/3rdParty/lazy_loader/__init__.py
Instead of devs digging through the code to learn that we're experimenting with this third party lib, we can mention it's existence and a short synopsis of what it does and how to use it. Perhaps link to the code itself? (ideally we could link to the generated API documentation).