8
Found out why my Python loops were so slow after 2 months of guessing
I was messing with a project that reads through a big CSV file, like 50000 rows of data. It was taking forever to process. I finally looked up list comprehensions vs for loops and turns out the built in stuff in Python is way faster. I rewrote one loop and it cut the time from 12 seconds to under 2 seconds. Has anyone else had a moment where they realized they were doing something the hard way for way too long?
3 comments
Log in to join the discussion
Log In3 Comments
phoenix_bailey1mo ago
Oh man, that's like finding out your phone has a flashlight after two years of using a candle. At least you got there eventually, right?
8
the_hayden1mo ago
Knew a guy who spent months using his tablet's front camera before realizing there was a better one on the back.
6
leo_black761mo ago
Oh totally, I've had that exact feeling with so many things. It's like how people will use a dull knife forever because they don't know you can sharpen it. The problem is we get used to doing something one way and never stop to ask if there's a better way. Most of the time we're just working harder not smarter. I started noticing this with my own habits like how I'd always walk the long way to the store because I learned the route once and never checked if there was a shortcut. Once you start looking for those little inefficiencies you find them everywhere. It's honestly kinda crazy how much time we waste just by being too lazy to google something or ask for help.
4