4 ms·
It's to make imports lazy, to solve the issue of slow import at startup.
by kccqzy 1y ago
It's to make imports lazy, to solve the issue of slow import at startup.
- falcor84 1y agoWhile there are some cases where lazy imports are appropriate, this function, and the vast majority of such lazy imports that I get from Claude are not. In particular, I can't think of any non-pathological situation where a python developer should import logging and update logging.basicConfig within an inner function.
- Maxion 1y agoIt's also a trick in python to deal with circular imports.
- jamster02 1y agoI also recently ran into a problem when unit testing and monkey patching where I had to import after monkey patching, so in the function itself.