Make use of compiled .pyc files to speed-up lambda cold starts and further slim the package size
hrist0stoichev opened this issue · comments
Hristo Stoychev commented
Is there an existing issue for this?
- I have searched existing issues, it hasn't been reported yet
Use case description
Right now slim: true
will remove all .pyc
and .pyo
files but those are actually more useful than .py
files for 2 main reasons:
- They are smaller in size as compared to
.py
files. - They will be generated on cold starts anyways, so having them will make cold-starts faster.
Going even deeper, the -OO
flag can be used so that .pyo
files are even smaller.
Proposed solution (optional)
On this flow chart you can see how the python lookup-mechanism works.
So, the easiest solution would be to just replace all .py
files with their .py[c|o]
counterparts coming from __pycache__
.