Issue36735
Created on 2019-04-26 18:50 by michalgr, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg340937 - (view) | Author: Michal Gregorczyk (michalgr) | Date: 2019-04-26 18:50 | |
Hi I am cross-compiling Python3.6 for Android and noticed that the final result is quite large (12mb of python3 binary + over 130mb of files under lib/python3.6). Do you have any suggestions how to reduce that size so that the result is more suitable for devices with constrained disks ? Here are two ideas that come to my mind: 1. not compiling everything to *.pyc files *.pyc files contribute 69mb, I expect that most of the files will not be imported 2. not including lib/python3.6/test Documentation says that the module contains regression tests for Python (https://docs.python.org/3/library/test.html). The directory adds 56MB, can I just remove it ? Should I keep some of the files because remaining parts of standard library refer it ? Does any of these seem unreasonable or fishy ? Are there configure options or make targets that already skip pyc and test ? Are there any other tips how to reduce size? Thanks |
|||
| msg340953 - (view) | Author: Berker Peksag (berker.peksag) * ![]() |
Date: 2019-04-27 00:09 | |
Replying your second question: I think most Linux distributions strip the Lib/test/ directory, so it should be safe to just remove it. We don't refer to it from the standard library. The helpers documented at https://docs.python.org/3/library/test.html are only used by Lib/test. |
|||
| msg340977 - (view) | Author: Stefan Behnel (scoder) * ![]() |
Date: 2019-04-27 10:22 | |
Make sure you use CFLAGS that limit the amount of debug data in the binaries. "-g1" in gcc should be enough to get stack traces on crashes, while reducing the binaries quite considerably compared to the default. "-g0" will give another visible reduction but removes all debug symbols, thus making it difficult to diagnose problems remotely. Apart from that, there used to be support for stuffing the standard library into a zip file, which shrinks .py and .pyc files by a good margin. Not sure what the status of that is, though, since I never needed it. And finally, I'm not sure if this is worth a (bug) ticket, rather than starting a discussion on python-list. Since this is a usage and deployment issue, the larger audience there might have more ideas and experience with things that might work without changing CPython for it. In any case, there will be no changes from the CPython side for this regarding Python 3.6. Anything this ticket might result in would be targeted for a future yet-to-be-released Python version. |
|||
| msg341131 - (view) | Author: Michal Gregorczyk (michalgr) | Date: 2019-04-30 01:44 | |
Thank you. I'm closing and will ask on python-list as suggested |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:14 | admin | set | github: 80916 |
| 2019-04-30 01:44:43 | michalgr | set | status: open -> closed resolution: not a bug messages: + msg341131 stage: resolved |
| 2019-04-27 13:19:46 | xtreak | set | nosy:
+ xdegaye |
| 2019-04-27 10:25:29 | scoder | set | nosy:
- scoder |
| 2019-04-27 10:22:41 | scoder | set | nosy:
+ scoder messages: + msg340977 |
| 2019-04-27 00:09:38 | berker.peksag | set | nosy:
+ berker.peksag messages: + msg340953 |
| 2019-04-26 18:50:06 | michalgr | create | |
