[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2020-02-12 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2020-02-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 8c579b1cc86053473eb052b76327279476740c9b by Serhiy Storchaka in branch 'master': bpo-32856: Optimize the assignment idiom in comprehensions. (GH-16814) https://github.com/python/cpython/commit/8c579b1cc86053473eb052b76327279476740c9b

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2020-01-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I want to merge PR 16814 if there are no objections. -- ___ Python tracker ___ ___

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-11-27 Thread Brett Cannon
Change by Brett Cannon : -- nosy: -brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-11-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > However, that's still going to be clearer to most readers than writing It is subjective. To me, j+1/j looks clearer than (j:=i*i)+1/j. In addition, the for-as-assignment idiom is more powerful in context of comprehensions, it allows to set an initial

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-10-23 Thread Josh Rosenberg
Josh Rosenberg added the comment: OOC, rather than optimizing a fairly ugly use case, might another approach be to make walrus less leaky? Even if observable leakage is considered desirable, it strikes me that use cases for walrus in genexprs and comprehensions likely break up into: 1.

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-10-21 Thread Yury Selivanov
Change by Yury Selivanov : -- nosy: -yselivanov ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-10-20 Thread Nick Coghlan
Nick Coghlan added the comment: The benefit offered by the parent local scoping was that it made assignment expressions usable as a straightforward way to implement comprehension-based accumulators where you actually do want access to the final value after the comprehension completes (for

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-10-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I just discovered that the assignment operator leaks variables > out of comprehensions. > ... > So it does not supersedes this optimization. That's a real bummer. IIRC, it was discussion of this proposal that motivated the creation of the walrus

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-10-15 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +16365 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16814 ___ Python tracker ___

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-10-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I just discovered that the assignment operator leaks variables out of comprehensions. >>> [(j:=i*i)+1/j for i in range(1, 3)] [2.0, 4.25] >>> j 4 >>> g = ((j:=i*i*i)+1/j for i in range(1, 3)) >>> list(g) [2.0, 8.125] >>> j 8 So it does not supersedes this

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-03-07 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-03-07 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: fixed -> rejected ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2019-03-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Closed in favor of PEP 572. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-25 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- priority: normal -> low ___ Python tracker ___

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-19 Thread Stefan Behnel
Change by Stefan Behnel : -- nosy: +scoder ___ Python tracker ___ ___ Python-bugs-list

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-16 Thread Yury Selivanov
Yury Selivanov added the comment: I'm still not sure whether we should enable this optimization or not. I haven't ever seen this pattern used in any Python code I worked with, so I suspect it's quite a rare hack. Giving it a fast-path would give this pattern extra

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here are some microbenchmarks. But since this code always is a part of complex expression it may be not make sense to talk about its pure speed. $ ./python -m timeit -s 'a = list(range(1000))' -- '[y for x in a for y in [x]]'

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is. -- ___ Python tracker ___ ___

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: +1 Please also support using a one-element tuple: `for y in (f(x),)` -- nosy: +steven.daprano ___ Python tracker

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-16 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +5487 stage: -> patch review ___ Python tracker ___

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-16 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch, patch pull_requests: +5486, 5487 stage: -> patch review ___ Python tracker

[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-16 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : There were a number of discussions about adding new syntax for temporary variables in comprehensions. The last was started yesterday on Python-Ideas (https://mail.python.org/pipermail/python-ideas/2018-February/048971.html).