Remove unused code automatically from large modules like numpy, pandas
<p>I'm creating a tool for my company's developers that will take a python project, zip it up with the required modules from the <code>site-packages</code> of a <code>virtualenv</code>, and run the code in an AWS Lambda function. I need to do this because Lambda doesn't come with 3rd party modules, and also won't let you install using <code>pip</code>, so I have to bring them all myself. The problem is that there's also a 250mb limit for the total amount of code, and if I have <code>numpy</code>+<code>pandas</code>, that's already over the limit. However, the developers aren't using nearly the full functionality of these modules, so the actual amount of code being used is tiny in comparison. I'd like something that'll strip out at least some of the unused code based on what the developer's project uses, or at least give me enough information to where I can write a script to remove the dead code automatically. Does this exist, or is it at least partially implemented?</p>