News for hackers. Stuff that matters.
Re:How I Got a 2x Speedup With One Line of Code by AznHisoka on Thursday November 14, 2013 @03:56PM (#6735501)
I got a 1000 X speedup by removing a sleep(100000) line once. Not as impressive though.
Re:How I Got a 2x Speedup With One Line of Code by wiredfool on Thursday November 14, 2013 @04:28PM (#6735736)
I got a 2gb reduction in memory usage and orders of magnitude speedup by adding an _ in one line once.
Re:How I Got a 2x Speedup With One Line of Code by Dylan16807 on Thursday November 14, 2013 @04:40PM (#6735818)
Care to explain that? I don't get it.
Re:How I Got a 2x Speedup With One Line of Code by wiredfool on Thursday November 14, 2013 @04:46PM (#6735851)
It was a long involved bug chase, but some django middleware had an optional cache of some s3 information. The actual variable was self._something, with an @property on self.something so that the getter would backfill the metadata if it didn't exist.

In the code, it was checking if self.something existed, and then doing something else if it didn't. This triggered the lazy getter, and had the effect of pulling in the metadata for a 300k item s3 bucket.

Checking for self._something correctly returned None, it then checked s3 for the item, and uploaded it directly.

Re:How I Got a 2x Speedup With One Line of Code by xster on Thursday November 14, 2013 @09:01PM (#6737231)
Ya, the title is pretty link bait-y. Just think of all the people who clicked the link and then found out they have no interest in sorting.

Title: I saved the world!!!#$^%!1111 Content: I was about to step on an ant today and narrowly missed it, saving the universe and all of existence for that ant.

Re:How I Got a 2x Speedup With One Line of Code by pkolaczk on Thursday November 14, 2013 @04:48PM (#6735870)
And I got an infinite memory usage improvement by adding one missing delete once. :D