Skip to content

Implement PEP 572: Assignment Expressions #2636

@scoder

Description

@scoder

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions