<h4 dir="auto">Code Sample</h4>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# Build pandas
python3 -m pip install -t build --no-binary pandas pandas==0.22.0

# Measure size
du -sh build/pandas

# Strip binaries
find build/pandas -name &quot;*.so&quot;|xargs strip

# Measure -drastically reduced- size
du -sh build/pandas"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> Build pandas</span>
python3 -m pip install -t build --no-binary pandas pandas==0.22.0

<span class="pl-c"><span class="pl-c">#</span> Measure size</span>
du -sh build/pandas

<span class="pl-c"><span class="pl-c">#</span> Strip binaries</span>
find build/pandas -name <span class="pl-s"><span class="pl-pds">"</span>*.so<span class="pl-pds">"</span></span><span class="pl-k">|</span>xargs strip

<span class="pl-c"><span class="pl-c">#</span> Measure -drastically reduced- size</span>
du -sh build/pandas</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">When building pandas from source and running the command strip, the resulting folder is 54% lighter than when using the manylinux wheel (via pip).</p>
<blockquote>
<p dir="auto">[...] the strip program removes inessential information from executable binary programs and object files, thus potentially resulting in better performance and sometimes significantly less disk space usage<br>
<a href="https://en.wikipedia.org/wiki/Strip_(Unix)" rel="nofollow">https://en.wikipedia.org/wiki/Strip_(Unix)</a></p>
</blockquote>
<p dir="auto">This is probably harmless on most systems, yet it is quite important in size-constrained systems (such as AWS Lambda).</p>
<p dir="auto">Some developers have resorted to distributing their own stripped binaries (e.g. lambda packages for the serverless framework zappa), but it seems like a makeshift solution.</p>
<p dir="auto">I think the problem should be solved upstream, as each library should be responsible for packaging their own optimized binaries.</p>
<blockquote>
<p dir="auto">An <a href="https://github.com/numpy/numpy/issues/10920" data-hovercard-type="issue" data-hovercard-url="/numpy/numpy/issues/10920/hovercard">issue</a> has also been opened regarding <code class="notranslate">numpy</code>, as it is a dependency of <code class="notranslate">pandas</code> and they both end up using a lot of unneccesary disk space.</p>
</blockquote>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.6.2.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.9.87-linuxkit-aufs<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: None<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.22.0<br>
pytest: None<br>
pip: 9.0.1<br>
setuptools: 36.2.7<br>
Cython: None<br>
numpy: 1.14.2<br>
scipy: None<br>
pyarrow: None<br>
xarray: None<br>
IPython: None<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.7.2<br>
pytz: 2018.4<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: None<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: None<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: None<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>
<h4 dir="auto">How to replicate</h4>
<h5 dir="auto">System specifications</h5>
<p dir="auto">Every command below has been executed using the <code class="notranslate">amazonlinux</code> docker image.<br>
<a href="https://hub.docker.com/_/amazonlinux/" rel="nofollow">https://hub.docker.com/_/amazonlinux/</a></p>
<p dir="auto">Pandas version: <code class="notranslate">0.22.0</code><br>
Python version: <code class="notranslate">3.6.2</code></p>
<h5 dir="auto">Prepare docker image</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker run -it amazonlinux bash
yum update -y
yum install -y findutils binutils python36-devel gcc gcc-c++"><pre class="notranslate"><code class="notranslate">docker run -it amazonlinux bash
yum update -y
yum install -y findutils binutils python36-devel gcc gcc-c++
</code></pre></div>
<h5 dir="auto">Install wheel &amp; measure package size</h5>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python3 -m pip install -t wheel pandas==0.22.0
du -sh wheel/pandas"><pre class="notranslate">python3 -m pip install -t wheel pandas==0.22.0
du -sh wheel/pandas</pre></div>
<p dir="auto">--&gt; <strong>111 MB</strong></p>
<p dir="auto">Try <a href="https://en.wikipedia.org/wiki/Strip_(Unix)" rel="nofollow">strip</a>:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="find wheel/pandas -name &quot;*.so&quot;|xargs strip
du -sh wheel/pandas"><pre class="notranslate">find wheel/pandas -name <span class="pl-s"><span class="pl-pds">"</span>*.so<span class="pl-pds">"</span></span><span class="pl-k">|</span>xargs strip
du -sh wheel/pandas</pre></div>
<p dir="auto">--&gt; 52 MB</p>
<p dir="auto">Almost 50% of the binary size can be stripped.</p>
<h5 dir="auto">Build from source &amp; measure package size</h5>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="python3 -m pip install -t build --no-binary pandas pandas==0.22.0
du -sh build/pandas"><pre class="notranslate">python3 -m pip install -t build --no-binary pandas pandas==0.22.0
du -sh build/pandas</pre></div>
<p dir="auto">--&gt; 107 MB</p>
<p dir="auto">Try <a href="https://en.wikipedia.org/wiki/Strip_(Unix)" rel="nofollow">strip</a>:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="find build/pandas -name &quot;*.so&quot;|xargs strip
du -sh build/pandas"><pre class="notranslate">find build/pandas -name <span class="pl-s"><span class="pl-pds">"</span>*.so<span class="pl-pds">"</span></span><span class="pl-k">|</span>xargs strip
du -sh build/pandas</pre></div>
<p dir="auto">--&gt; <strong>51 MB</strong></p>
<p dir="auto">On the next release, please update the multibuild submodule to <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/matthew-brett/multibuild/commit/b2748e5d4d2ae6e45b130bdf8e24361083341e9a/hovercard" href="https://github.com/matthew-brett/multibuild/commit/b2748e5d4d2ae6e45b130bdf8e24361083341e9a">matthew-brett/multibuild@<tt>b2748e5</tt></a> or newer. This should reduce the size of the Pandas wheels from 27M to 11M by excluding unnecessary debug symbols.</p>
<p dir="auto">ref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="294190687" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/19531" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/19531/hovercard" href="https://github.com/pandas-dev/pandas/issues/19531">pandas-dev/pandas#19531</a></p>