aiidalab / ipyoptimade

Import structures in jupyter notebook using OPTIMADE
MIT License
2 stars 1 forks source link

Lazy import of pandas #19

Open danielhollas opened 6 months ago

danielhollas commented 6 months ago

This is a low-hanging fruit for speeding up the import of ipyoptimade package.

pandas is currently imported only in src/ipyoptimade/subwidgets/output_summary.py

I've already done the same in AWB, so this win should directly translate into faster app load speed. (locally I see ~200ms difference, would probably be bigger in the Demo container).

cc @superstar54 @unkcpz

For reference, I benchmark the import time with

pipx install tuna
python -Ximporttime -c "import ipyoptimade" 2> importtime.out
tuna importtime.out

To get this

image

danielhollas commented 6 months ago

I'll just note that the next big offender is optimade.models.

image

I suspect (but did not verify) that this is due to pydantic models. I wonder if using the defer_build option, as discussed here would improve that. But that would have to be made in the optimade package.

unkcpz commented 6 months ago

Okay, cool! Let's do pandas first. BTW, the performance test by @superstar54 was did with old aiida-core 2.4 without your performance improvements.