Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this issue exists on the latest version of pandas.
-
[ ] I have confirmed this issue exists on the main branch of pandas.
Reproducible Example
Hello,
I was doing some memory profiling of an application that employs, among other libraries, Pandas. I have noticed it was using more than 50MB of memory just from imports, so I dug up and found that this line
import pandas._libs.pandas_parser
is the culprit.
Looking at the imported lib files they seem pretty small, so I wonder, what would be causing this memory blowup? I have added some files for reproducibility. Machine and Python details below.
Installed Versions
Prior Performance
No response
Comment From: LucaCerina
Tested also on a Linux machine, got the same results.
Line # Mem usage Increment Occurrences Line Contents
=============================================================
197 23.051 MiB 23.051 MiB 1 @profile
198 def import_8():
199 74.832 MiB 51.781 MiB 1 import pandas._libs.pandas_parser # isort: skip # type: ignore[reportUnusedImport]
200 74.832 MiB 0.000 MiB 1 import pandas._libs.pandas_datetime # noqa: F401 # isort: skip # type: ignore[reportUnusedImport]
201 74.832 MiB 0.000 MiB 1 from pandas._libs.interval import Interval
202 74.832 MiB 0.000 MiB 1 from pandas._libs.tslibs import (
203 NaT,
204 NaTType,
205 OutOfBoundsDatetime,
206 Period,
207 Timedelta,
208 Timestamp,
209 iNaT,
210 )
Installed Versions
Comment From: jbrockmendel
Aside from "make pandas smaller", what is the ask here? parsers.pyx imports from all over pandas. Even if we could get stuff out of it, those imports would still occur elsewhere
Comment From: LucaCerina
I am just trying to understand why if blows up so much at import time. I checked the parser C and pyx files and at a first glance I didn't see any giant malloc.
Is it a known problem I can help with?
There are obvious benefits in a smaller Pandas, and other Cython/C/etc heavy libraries (Numpy is 7MB in comparison) don't seem to have the same problem.
Comment From: jbrockmendel
If you can find a way to trim the import size, that would be very welcome. xref #52654