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

Support for walrus operator #513

Open
greenozon opened this issue Aug 17, 2024 · 0 comments
Open

Support for walrus operator #513

greenozon opened this issue Aug 17, 2024 · 0 comments

Comments

@greenozon
Copy link
Contributor

Python has an interesting feature - walrus operator

if you try to decompile it, the output would be pretty strange, for example

the code

y = 1
x = (y:=10)

decompiles as

c:\Dev\>pycdc walrus.cpython-312.pyc
# Source Generated with Decompyle++
# File: walrus.cpython-312.pyc (Python 3.12)

y = 1
y = 10
x = None

corresponsing disassembly is:

c:\Dev\>pycdas walrus.cpython-312.pyc
walrus.cpython-312.pyc (Python 3.12)
[Code]
    File Name: walrus.py
    Object Name: <module>
    Qualified Name: <module>
    Arg Count: 0
    Pos Only Arg Count: 0
    KW Only Arg Count: 0
    Stack Size: 2
    Flags: 0x00000000
    [Names]
        'y'
        'x'
    [Locals+Names]
    [Constants]
        1
        10
        None
    [Disassembly]
        0       RESUME                          0
        2       LOAD_CONST                      0: 1
        4       STORE_NAME                      0: y
        6       LOAD_CONST                      1: 10
        8       COPY                            1
        10      STORE_NAME                      0: y
        12      STORE_NAME                      1: x
        14      RETURN_CONST                    2: None

walrus-files.zip

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

No branches or pull requests

1 participant