为什么我的 Stackless 可执行文件小得多
我为 Stackless Python 竞赛编写了一些游戏,需要创建一个可执行文件。但不小心,我使用了 CPython 2.6 而不是使用 Stackless Python 2.5 来构建可执行文件。我正确地重建,发现 dist 的最终大小从 30 MB 多一点下降到 8 MB 左右。出于好奇,这到底是为什么?作为猜测,我敢说这是因为我在 CPython 中安装了 Twisted 和 Qt4 等库,但没有在 Stackless 中安装,并且在所有内容中都安装了 Py2exe 包,无论是否使用它们(可能是因为您始终可以动态调用代码),但如果有人真的知道,我会有兴趣了解原因。
I wrote a few games for a competition in Stackless Python and needed to create an executable. Accidentally though, I used CPython 2.6 instead of using Stackless Python 2.5 to build the executable. I rebuilt correctly, and found that the final size of the dist was down from slightly over 30 MB down to around 8. Out of curiosity, why exactly was this? As a guess, I would hazard that it is because I have installed libraries like Twisted and Qt4 in CPython, but not in Stackless, and Py2exe packages in everything, whether or not they are used (possibly because you can always call code dynamically), but if anyone actually knows, I would be interested in learning why.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
py2exe 确实会查看您的依赖项,并且仅包含它认为您正在使用的依赖项。如果排除列表包含额外模块,您可以手动指定排除列表。
查看这个 py2exe 脚本(将“setup.py”替换为您自己的主 py 文件的名称)。此设置脚本会跳过捆绑步骤,因此您可以查看哪些内容占用了最多的空间。
py2exe does look through to your dependencies and only includes the ones it thinks you're using. You can manually specify an exclude list if it's including extra modules.
Check out this py2exe script (replace "setup.py" with the name of your own main py file). This setup script skips the bundling step, so you can look through to see what is taking up the most space.