Does importing too many classes (definitions) can make the execution much longer?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 101
- Joined: Sun Jul 24, 2022 12:49 pm
Does importing too many classes (definitions) can make the execution much longer?
Does importing too many classes (just declarations nothing executable) can make execution of FreeCAD python program much longer?
Re: Does importing too many classes (definitions) can make the execution much longer?
As soon as it is enough to need slower memory, e.g. swap space on a hard disc, it will make a program slower.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Does importing too many classes (definitions) can make the execution much longer?
I don't think it matters so much in terms of execution time after all the imports are done, but I haven't tested it. You would need to do some profiling to see for sure. Obviously, the imports themselves will take some time to do, which can be quite noticeable if there are many packages to be imported. If all the packages are not needed every time the script is executed, then it can be sensible to do the imports only as needed rather than importing everything upon startup at the top of the source code.