[Python-Dev] The `for y in [x]` idiom in comprehensions

Serhiy Storchaka storchaka at gmail.com
Sun Feb 25 09:36:16 EST 2018
23.02.18 19:30, Guido van Rossum пише:
> I'm not saying anything new here, but since you asked specifically for 
> my opinion: I don't care for the idiom; it's never occurred to me 
> before, and it smells of cleverness. If I saw it in a code review I 
> would probably ask for a regular for-loop to make the code more 
> maintainable.
> 
> But if you say it's useful for some class of users and it would be more 
> useful if it was faster, I'm fine with the optimization. The 
> optimization is also clever, and here I appreciate cleverness!

Thank you. Given the contradictory relation of other core developers to 
this idiom, and small total effect of this optimization (since the 
problem solved by using this idiom is rarely occurred), I'm inclined to 
defer this optimization on to some time (months or years). Maybe 
something will be changed during this period: either this idiom will 
become more popular, or new arguments against using it will be found, or 
better solution will be found, or this optimization will become the part 
of more general optimization.



More information about the Python-Dev mailing list