Mathias711
Mathias711

Reputation: 6658

How much can I reduce the filesize by only importing useful functions in combination with PyInstaller?

When I create an .exe with PyInstaller, the exe is roughly 160 MB. This includes all the import from my python script (e.g., numpy, pandas, sys). How much can the filesize be reduced if I only include the functions that I need?

For example:

from numpy import cumsum, ravel, diff, append

vs

import numpy as np

Will this be worth the effort to completely re-evaluate my script(s)?

Upvotes: 1

Views: 181

Answers (1)

Andrea Corbellini
Andrea Corbellini

Reputation: 17751

No. The code for all the functions would still be there, even if you don't use them. If you include numpy as part of your executable, then the whole numpy code is there, because PyInstaller will never look at your code, it will just pack everything into a single executable file.

Upvotes: 2

Related Questions