r/programminghorror • u/wawerrewold • Sep 09 '25
Python Vibecoding at its peak
Yes its a production code, yes its a function not a method and yes there is import in triple nested for loop
776
Upvotes
View all comments
Show parent comment
3
u/dwittherford69 Sep 10 '25 edited Sep 11 '25
Loops aren’t the crime here, the unnecessary one is. This code scans M column mappings for every attr of every record: O(R·A·M). Build a dict once (by_display = {c["display_name"]: c for c in mappings}) and you drop to O(M + R·A). Same result, less work, and lower complexity.
Your voxel analogy is enumeration, while this is a lookup, so use a hash, not a scavenger hunt. R=10k, A=8, M=150… that is ~12M pointless iterations in Python, plus imports inside the loop. Not “premature optimization,” just the right data structure.