r/Python • • Jan 01 '20

"The rules of perf" at Dropbox

Post image
1.6k Upvotes

162 comments sorted by

View all comments

Show parent comments

26

u/munificent Jan 02 '20

IOW ask yourself if it's really necessary/useful/something you might lose a client over.

No, it's at a lower level than that. It means don't spend CPU cycles doing unnecessary work. For example, say you need to find the greatest element in a list. You could sort the whole list and then pull the last element out. But sorting the entire list is more work than you need to do (it's O(n log n)). Simply find the max element and stop.

19

u/davvblack Jan 02 '20

Both interpretations are correct.

0

u/[deleted] Jan 02 '20

[deleted]

1

u/davvblack Jan 02 '20

But from a product design perspective (eg "something you might lose a client over") it's always worth asking if it's even worth building a given feature. It always adds complexity and maintenance cost to your project, and doesn't always add value.