Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    or a more complex dense code for the sake of performance is "high" performance among requirements? Commented Dec 15, 2022 at 11:36
  • In my case at the moment not really, it's just the first POC version of the system I'm writing. But it could be later, especially since the volume of data I'm using is regularly growing. Slowly, I'd say tens or hundreds per day, but it's growing. Commented Dec 15, 2022 at 11:40
  • 4
    Unless you need it. YAGNI prevails. So you make the simplest solution possible, perhaps, performing the operation in each iteration. Then you compare its performance with the one expected or desired. You can't optimize something unless you have something to optimize. Commented Dec 15, 2022 at 11:45
  • 1
    I'd make a strong case for putting any complicated list comprehensions into a function, so they become just "do_something(x) for x in y". @Amon 's answer is a good one. Commented Dec 15, 2022 at 13:25
  • I'll give you the advice that was given to me when I first started coding; do not prematurely optimize your code. Get it working first in a way that's readable. THEN once it's working, see if you even NEED to optimize. Folk around our office often nickname it list incomprehension because of how quickly the code can become ugly to read. Commented Dec 22, 2022 at 16:18