I don't understand this – why would you import a package into your code that you weren't using?
So it turns out people who care about performance already turn all Python imports into local ones under the hood: both Hudson River Trading, and Meta's production python auto lazy import:
5
1
7
imagine an app that renders a matplotlib image or outputs to a pandas dataframe on a user request, not having to load that package until it’s being used makes the startup time much faster since python imports every package into the global namespace when it’s at the top of the file
Replying to @pdrmnvd
I guess I had a blind spot because I don't really code things that way. Usually my apps are focused on one thing as a service so I use everything I import.

Oct 10, 2025 · 8:39 AM UTC

1
1
Replying to @hammer_mt
yea i think this would mostly benefit a lot of libraries and frameworks snowflake package for example supports writing to pandas, and using aws which depends on pretty large packages
1
1
I also realized that most people are setting up their environments a lot? I tend to set up one environment and then I use it for hundreds of different notebook experiments etc so the initial slow loading wasn't a big part of my day.
1