T
14

Found out my code was running 60% slower because of one dumb habit

I was working on a Python script for a side project and it was taking forever to process a list of names. Turns out I was using a regular for loop with .append() instead of a list comprehension, and the difference was massive after I read a post on Stack Overflow. Has anyone else found a simple change that saved them way more time than expected?
2 comments

Log in to join the discussion

Log In
2 Comments
kelly338
kelly33816d ago
Yeah, using .join() on strings instead of += saved me like 80% time once.
6
grant.parker
Spent an hour debugging a typo in a variable name once.
2