News for hackers. Stuff that matters.
Re:LLMs are mortally terrified of exceptions by falcor84 on Thursday October 09, 2025 @04:22PM (#45532629)
That code has many issues, but the one that bothers me the most in practice is this tendency of adding imports inside functions. I can only assume that it's an artifact of them optimizing for a minimal number of edits somewhere in the process, but I expect better.
Re:LLMs are mortally terrified of exceptions by natnat on Thursday October 09, 2025 @08:12PM (#45534315)
I think this has a lot to do with the mechanism of RoPE attention, where physical closeness in the code is a signal of relevance.
Re:LLMs are mortally terrified of exceptions by andrewmcwatters on Thursday October 09, 2025 @07:59PM (#45534248)
In very, very large projects, you end up finding that you want lazy initialization as much as possible, because it greatly affects startup times.
Re:LLMs are mortally terrified of exceptions by kccqzy on Thursday October 09, 2025 @04:57PM (#45533006)
It's to make imports lazy, to solve the issue of slow import at startup.
Re:LLMs are mortally terrified of exceptions by falcor84 on Thursday October 09, 2025 @05:26PM (#45533273)
While 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.

Re:LLMs are mortally terrified of exceptions by Maxion on Friday October 10, 2025 @01:21AM (#45535574)
It's also a trick in python to deal with circular imports.
Re:LLMs are mortally terrified of exceptions by jamster02 on Friday October 10, 2025 @09:45AM (#45538968)
I 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.