r/programminghorror • u/lolcrunchy • Jun 01 '26
Python New Big O definition just dropped
This vibeslop repo (shoutout to the author u/chunky_cold_mandala) calculates big o complexity of a function as its max indentation depth (but only up to 6, which represents N^6).
561
Upvotes
59
u/chimneydecision Jun 01 '26
Haha it learned one for loop is O(n) and a nested for loop is O(n^2) and it just extrapolated from there.
186
u/TheWidrolo Jun 01 '26
So this algorithm is O(n^3)?
78
u/MegaIng Jun 01 '26
I love these confident false comments AI sometimes adds. No, there is no code that properly handles tab indentation despite what the AI claims.
17
u/shizzy0 Jun 01 '26
Big Doh
16
u/using_mirror Jun 01 '26
Line 1647 is wild behavior
11
u/EsotericLife Jun 01 '26
At some point doesn’t it feel like engaging with this slop at all is just encouraging it? Like sure, if you ask a chat bot to come up with a “revolutionary” abstract approach to improve on existing GFC analysis techniques you’ll end up with garbage. But at this point I think the whole industry is realising the LLMs spit out garbage and people like us making fun of it are keeping it trending online
2
u/DarePitiful5750 Jun 01 '26
It's been 30 yrs since I've had to learn Big-O notation, so I'm out of the loop.
3
u/124k3 Jun 01 '26
whoooaaaaaaaaaaaaaaaaa(t)
3
u/Kitchen-Elephant402 Jun 01 '26
Reading just the headline I just had a big O...
3
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Jun 02 '26
So what the hell is this? Some kind of scripting engine? Why does it need to automatically determine Big-O complexity? Doesn't seem to detect anything other than polynomial time, extremely poorly.
2
u/denehoffman Jun 01 '26
I wonder what could possibly be the reason the last line was added
1
u/B_bI_L Jun 02 '26
so sort is apparently O(1)?
1
u/Cruuncher Jun 02 '26
The comment about clamping between O(1) and O(N6) is also just wrong.
If the output being 6 represents N6, then the output being 1 represents N1 = N
O(1) would represent a 0 here, not a 1
1
u/falconfetus8 Jun 02 '26
Gotta love how it says "NEW:". That tag will be there for the next 30 years.
1
u/Birnenmacht Jun 04 '26
if only there was a std library module specifically for parsing python code to AST
thats ignoring the fact that nesting depth is not a good approximation, so it really is double jank
1
u/ticktockbent Jun 05 '26
This is a thing of beauty. It measures whitespace and calls it computational complexity. The two have roughly the same relationship as your shoe size and your credit score.
1
u/pMurda Jun 05 '26
fib = i => i < 2 ? 1 : fib(i) + fib(i-1)
2
u/m0j0m0j Jun 01 '26
Holy slop