[Python-Dev] PEP 572: Assignment Expressions (original) (raw)
Steve Holden steve at holdenweb.com
Tue Apr 24 07:37:06 EDT 2018
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
What facilities does the interpreter currently have for extracting common subexpressions, and how would it verify in such a dynamic environment that such extractions wouldn't alter the semantics of the program? Explicit (assignment using :=) is better than implicit (by optimizations hidden to the programmer).
regards Steve
Steve Holden
On Mon, Apr 23, 2018 at 6:13 PM, Sven R. Kunze <srkunze at mail.de> wrote:
On 23.04.2018 17:59, Steve Holden wrote:
While Tim's expression might look (superficially) like C, the five-line alternative isn't exactly an inspiring example of Pythonicity, is it? What about diff = x - xbase if diff and gcd(diff, n) > 1: return gcd(diff, n) # or if (x - xbase) and gcd(x - xbase, n) > 1: return gcd(x - xbase, n)
and have the interpreter handle the optimization, or apply an lrucache? ;-) Cheers, Sven
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ steve%40holdenweb.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180424/b362f3d0/attachment.html>
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]