[Python-ideas] PEP 572: Statement-Local Name Bindings

Kirill Balunov kirillbalunov at gmail.com
Wed Feb 28 09:14:27 EST 2018


 2018-02-28 16:49 GMT+03:00 Serhiy Storchaka <storchaka at gmail.com>:

> 28.02.18 00:27, Chris Angelico пише:
>
>> Example usage
>> =============
>>
>> These list comprehensions are all approximately equivalent::
>>
>>      # Calling the function twice
>>      stuff = [[f(x), f(x)] for x in range(5)]
>>
>
> Other options:
>
>     stuff = [[y, y] for y in (f(x) for x in range(5))]
>

Why not `stuff = [[y, y] for y in map(f, range(5))]`?  It is currently the
fastest and most readable version IMHO.

With kind regards,
-gdg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180228/735ba7fd/attachment-0001.html>


More information about the Python-ideas mailing list