Re:PEP 572: Python assignment expressions has been accepted
by gshulegaard on Tuesday July 03, 2018 @09:24PM
(#17454756)
I'm aware `foo(z)` gets called twice, but I wouldn't choose to break it into the `for` loop you mention:
[bar(x) for x in map(foo, stuff) if x]
I was just trying to be as close to the original as possible.I do find it odd you call out the calling of `foo` twice as a performance drain but then use the chief example of:
> When I'm developing out an idea and just want to see if the code works and passes my tests, I would rather have the option to insert behavior swiftly without having to reformat an entire block of code.
Tests are not something I (personally) consider to be performance sensitive. But like I said I am sort of neutral on this change. I don't really see a massive benefit to it, so I would personally air on the side of "don't add" but I'm not mad it's being added. It's a "meh" for me.
Re:PEP 572: Python assignment expressions has been accepted
by bjd2385 on Tuesday July 03, 2018 @07:41PM
(#17454426)
Honestly, after seeing the first list comprehension, I can tell that this feature will probably increase code readability for me, but it's definitely going to take more thought to understand where values are coming from.
When I'm developing out an idea and just want to see if the code works and passes my tests, I would rather have the option to insert behavior swiftly without having to reformat an entire block of code. Then when reviewing my code or deciding whether to make it reusable for something else, I can go back and clean things up.