Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I got a 2gb reduction in memory usage and orders of magnitude speedup by adding an _ in one line once.


Care to explain that? I don't get it.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: