8 ms·
> Optimized the zip size by removing .pyc files and unnecessary libraries Why do you remove the .pyc files instead of the .py files? Keeping the .pyc bytecode
by kylebarron 7y ago
> Optimized the zip size by removing .pyc files and unnecessary libraries
Why do you remove the .pyc files instead of the .py files? Keeping the .pyc bytecode means that it can skip the bytecode compiling when used.
Some bootstrapping code I use from [0] is helpful to remove the uncompiled .py files.
[0]: https://github.com/RemotePixel/cogeo-layer/blob/f04d14ebf99dfcfa71ae5584a818956e91e8f0fa/scripts/create-lambda-layer.sh#L20-L23 https://github.com/RemotePixel/cogeo-layer/blob/f04d14ebf99d...
- fulafel 7y agoYou wouldn't be able to inspect the code anymore or see the plain text stack traces. Also does this actually work with the new model of .pyc files in __pycache__ dir?
- kylebarron 7y agoI mean I've used the code I linked as a lambda layer just fine. I never specifically looked in the zip archive to make sure .py files weren't included, but from that bash script I think they're removed.