Does pyinstaller do dead code elimination/code optimizaiton? #8948
-
Hey, Thanks for the work on In the JavaScript/C++ world there's the concept of tree-shaking (dead code elimination), I was wondering if |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Not really. The import analysis (based on
As far as I'm concerned, the answer is no. Just keeping things running around here takes enough effort. From my perspective, it would make more sense to prune your code (perhaps whole virtual environment?) using third-party tree-shaking tool (if it exists for python), test it unfrozen, and only freeze it with PyInstaller once you are reasonably sure that pruning did not break anything. |
Beta Was this translation helpful? Give feedback.
Not really.
The import analysis (based on
modulegraph
) might help us avoid collecting unused modules of a package, although in practice, due to indirect imports (e.g., programmatic imports with dynamically constructed module names) we often need to resort to collecting all modules from a package just to have things work. But there's no pruning of let's say unused functions or classes within the modules, etc. (Plus the contents of binary extensions and shared libraries cannot be split/pruned anyway).As far as I'm concerned, the answer is no. Just keeping things running around here takes enough effort.
From my perspective, it would make more sen…