[Python-ideas] Inline assignments using "given" clauses

Neil Girdhar mistersheik at gmail.com
Sat May 12 23:04:45 EDT 2018


Another benefit of given compared with := that I just thought of is this.
Suppose you have a generator like

(expression(f(x), y, z)
 for x in xs
 for y in ys(x)
 for z in zs(y))

With given notation you can optimize:

(expression(f_x, y, z)
 for x in xs
 given f_x = f(x)
 for y in ys(x)
 for z in zs(y))

whereas with :=, you can't.

Best,

Neil

On Sat, May 12, 2018 at 10:56 PM David Mertz <mertz at gnosis.cx> wrote:

> Are votes cast in Edwin Hewitt's Hyperreals? I had thought python-ideas
> voted in the domain R rather than *R. :-)
>
> On Sat, May 12, 2018, 5:20 PM Stephen J. Turnbull <
> turnbull.stephen.fw at u.tsukuba.ac.jp> wrote:
>
>> David Mertz writes:
>>
>>  > Only the BDFL has a vote with non-zero weight.
>>
>> "Infinitesimal" != "zero".
>>
>> Pedantically yours,
>>
>> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/CFuqwmE8s-E/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/CFuqwmE8s-E/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180512/a00ccd63/attachment-0001.html>


More information about the Python-ideas mailing list