[Python-Dev] PEP 572: Assignment Expressions (original) (raw)
Sven R. Kunze srkunze at mail.de
Mon Apr 23 13:13:00 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 ]
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 - x_base if diff and gcd(diff, n) > 1: return gcd(diff, n)
or
if (x - x_base) and gcd(x - x_base, n) > 1: return gcd(x - x_base, n)
and have the interpreter handle the optimization, or apply an lru_cache? ;-)
Cheers, Sven -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180423/06999679/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 ]