Lazy loading of python modules

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
etrombly
Posts: 144
Joined: Thu Dec 05, 2019 6:50 pm

Re: Lazy loading of python modules

Post by etrombly »

Copying to Ext works for the build, need to check the right path for install. Modified most of the external imports to use lazyloader in path. It cuts the workbench load time from about 15 seconds to around 3, everything still appears to be functioning correctly. It's committed to the branch I posted earlier.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Lazy loading of python modules

Post by sgrogan »

etrombly wrote: Fri Apr 10, 2020 12:57 am Copying to Ext works for the build, need to check the right path for install. Modified most of the external imports to use lazyloader in path. It cuts the workbench load time from about 15 seconds to around 3, everything still appears to be functioning correctly. It's committed to the branch I posted earlier.
Thanks.
I will try to build and test your branch on Win in the next days.
"fight the good fight"
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Lazy loading of python modules

Post by sgrogan »

etrombly wrote: Fri Apr 10, 2020 12:57 am It cuts the workbench load time from about 15 seconds to around 3
Everything installs OK. I think Ext is the proper place. Activation of Path is significantly improved. Nice work!
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20513 +4 (Git)
Build type: Release
Branch: lazyloader
Hash: a42219163aec573870a5f1f5f034a7396b6cb3f8
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)
"fight the good fight"
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Lazy loading of python modules

Post by Kunda1 »

sgrogan wrote: Sun Apr 12, 2020 2:46 pm
etrombly wrote: Fri Apr 10, 2020 12:57 am It cuts the workbench load time from about 15 seconds to around 3
Everything installs OK. I think Ext is the proper place. Activation of Path is significantly improved. Nice work!
Nice!
@sgrogan why not add it to src/3rdParty per the suggestion of @vocx ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
etrombly
Posts: 144
Joined: Thu Dec 05, 2019 6:50 pm

Re: Lazy loading of python modules

Post by etrombly »

Kunda1 wrote: Sun Apr 12, 2020 3:05 pm Nice!
@sgrogan why not add it to src/3rdParty per the suggestion of @vocx ?
3rdParty isn't on the python path. That's where I put it in the source, but install it to Ext.

Thanks for testing @sgrogan. Need to figure out why the tests are failing with python 2 now, don't have a dev environment setup for it though. May take me a while.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Lazy loading of python modules

Post by sgrogan »

etrombly wrote: Sun Apr 12, 2020 3:35 pm 3rdParty isn't on the python path. That's where I put it in the source, but install it to Ext.
I think this is the correct solution. Thanks @vocx as well. 3rdPary is the correct place in the src. We are trying not to have 3rd party source if there is a maintained package that can be a dependency. In this case we are using a small subset of the existing package so I think it makes sense to include in the src so we don't require the full python package.
etrombly wrote: Sun Apr 12, 2020 3:35 pm Thanks for testing @sgrogan. Need to figure out why the tests are failing with python 2 now, don't have a dev environment setup for it though. May take me a while.
IMHO I propose you ignore it. Or try/except it. We will be dropping PY2 as EOL after 0.19 release and I think the policy is to support PY2 "if its not too much trouble".
"fight the good fight"
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Lazy loading of python modules

Post by Kunda1 »

Question: Was documentation ever written for this functionality ? is it on the wiki ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Lazy loading of python modules

Post by sgrogan »

Kunda1 wrote: Sun Oct 18, 2020 12:27 pm Question: Was documentation ever written for this functionality ? is it on the wiki ?
https://wiki.freecadweb.org/Extra_python_modules
At the bottom of the page
"fight the good fight"
Post Reply