Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PEP 572: Assignment Expressions #2636

Closed
scoder opened this issue Sep 29, 2018 · 4 comments · Fixed by #3691
Closed

Implement PEP 572: Assignment Expressions #2636

scoder opened this issue Sep 29, 2018 · 4 comments · Fixed by #3691

Comments

@scoder
Copy link
Contributor

scoder commented Sep 29, 2018

See https://www.python.org/dev/peps/pep-0572

For Cython, this has a couple of consequences:

  • The parser needs to be extended to support the new syntax.
  • Assignments can now happen inside of expressions, which was previously impossible. Several syntax tree transformations assume that they can stop at an ExprNode, which they cannot any more in the future.
  • The control flow analysis needs updating to detect assigned names in expressions and correctly track their usage.
  • An assignment expression would probably always move the assigned expression into a temp variable and continue from there. There may be expressions from that rule (for simple C types) since C also supports assignments in expressions, but that sounds more like an optimisation than a requirement.
@spmsh
Copy link

spmsh commented Jun 18, 2020

Hi Team, is there any update on this one ? is PEP572 supported anytime soon ? Thanks !

@scoder
Copy link
Contributor Author

scoder commented Jun 18, 2020 via email

da-woods added a commit to da-woods/cython that referenced this issue Jun 18, 2020
Will eventually fix cython#2636

At the moment I think the parsing is far too lenient and
the error cases definitely aren't tested properly.

I also suspect (but don't know) that they don't work in fstrings.

Submitted mostly to see how much stuff it inadvertently breaks
da-woods added a commit to da-woods/cython that referenced this issue Jun 18, 2020
Will eventually fix cython#2636

At the moment I think the parsing is far too lenient and
the error cases definitely aren't tested properly.

I also suspect (but don't know) that they don't work in fstrings.

Submitted mostly to see how much stuff it inadvertently breaks
@ghost ghost mentioned this issue Aug 28, 2020
cdrini added a commit to cdrini/openlibrary that referenced this issue Sep 15, 2021
cdrini added a commit to cdrini/openlibrary that referenced this issue Sep 16, 2021
cdrini added a commit to cdrini/openlibrary that referenced this issue Sep 24, 2021
cdrini added a commit to cdrini/openlibrary that referenced this issue Oct 27, 2021
cdrini added a commit to cdrini/openlibrary that referenced this issue Oct 29, 2021
cdrini added a commit to cdrini/openlibrary that referenced this issue Oct 29, 2021
cdrini added a commit to cdrini/openlibrary that referenced this issue Nov 2, 2021
cdrini added a commit to cdrini/openlibrary that referenced this issue Nov 9, 2021
@scoder scoder added this to the 3.0 milestone Jan 27, 2022
@UlrikHjort
Copy link

Hi All,
What is the current status regarding adding the assignment expression operator ? Seems to me that all PRs so far had been closed without a fix ?

@scoder
Copy link
Contributor Author

scoder commented Mar 16, 2022

It's not released yet. Wait for 3.0a11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants