Re:Python 3.11 vs 3.10 performance
by teekert on Wednesday July 06, 2022 @01:15PM
(#32003934)
Whenever I nest a list comprehension I feel dirty anyway, I wonder if a better error message will help solve something that is just hard to grasp sometimes.
[ Parent
| on HN ]
Re:Python 3.11 vs 3.10 performance
by 8organicbits on Wednesday July 06, 2022 @01:47PM
(#32004376)
"Debugging is twice as hard as writing the code in the first place. Therfore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Rajanand
Although, personally, I enjoy python list comprehensions.
Re:Python 3.11 vs 3.10 performance
by timoteostewart on Wednesday July 06, 2022 @01:55PM
(#32004479)
I believe that quote about debugging being twice as hard as coding is by Brian Kernighan.
Re:Python 3.11 vs 3.10 performance
by 8organicbits on Wednesday July 06, 2022 @02:21PM
(#32004774)
Maybe, I grabbed the first matching quote I found. I can't attribute it on my own.
Re:Python 3.11 vs 3.10 performance
by timoteostewart on Wednesday July 06, 2022 @03:00PM
(#32005302)
No sweat. I’m a quote nerd so it jumped out at me
Re:Python 3.11 vs 3.10 performance
by mikepurvis on Wednesday July 06, 2022 @02:14PM
(#32004711)
Not even with nesting— as soon as it's long enough that I'm breaking it into multiple lines, I'm immediately like, okay this is long enough to just be a normal for-loop, or maybe a generator function. But it doesn't need to be a list comprehension any more.
All list comprehensions should error with message "FATAL PARSE ERROR: Will you really understand this in six months?"
Something like this I find ok (just a filter):
[x for x in y if x is not z]
Sometimes though, facilitated by Jupyter's notebooks making executing as you build the code very easy, I create a beast like this: [os.path.join([x for x in y if x is not z]) + '/bin' for a in b if 'temp' not in a]
Yes this is fictional and probably contains an error but you get the point, you can filter lists of lists like this, but it's really unfriendly to anyone trying to understand it later.
Re:Python 3.11 vs 3.10 performance
by wheelerof4te on Wednesday July 06, 2022 @03:11PM
(#32005422)
List comprehensions should be used for making quick lists that contain simple calculations or filters.
Anything more will come back to bite you later.
Re:Python 3.11 vs 3.10 performance
by TremendousJudge on Wednesday July 06, 2022 @01:42PM
(#32004290)
If people complain about Rust's borrow checker already...