Relatively high memory usage
Created originally on Bitbucket by AdamChainz (Adam Johnson)
I ran tracemalloc
on my application on a code path that doesn’t use penpyxl code path and was surprised to see it still appeared in the top memory users. It appeared in slots 20 and 21 out of the top 25, where the top 10 are mostly Python internals. Each corresponds to ~1% memory usage:
#20: .../venv/lib/python3.6/site-packages/openpyxl/utils/cell.py:99: 492.8 KiB
for i in range(1, 18279):
#21: .../venv/lib/python3.6/site-packages/openpyxl/descriptors/base.py:19: 460.2 KiB
self.name = name
The first one looks like openpyxl assigns 18278 strings at import time for caching purpose. Perhaps these could be delayed until runtime by using a functools.lru_cache
?
The second is from the various descriptors throughout the codebase. I’m not sure there’s an easy win for simplifying them there, and they’re probably only appearing since there are so many such classes inside openpyxl
I’d submit a patch for lru_cache
but Mercurial is a bit beyond me.