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

CONTAINS_OP can provide the operation name #123363

Closed
Alexandr153 opened this issue Aug 26, 2024 · 3 comments
Closed

CONTAINS_OP can provide the operation name #123363

Alexandr153 opened this issue Aug 26, 2024 · 3 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@Alexandr153
Copy link
Contributor

Alexandr153 commented Aug 26, 2024

Feature or enhancement

Proposal:

When referring to the in and not in operator, the dis module does not display in COMPARE_OP which operator is being used

>>> dis.dis('a in b')
  0           0 RESUME                   0

  1           2 LOAD_NAME                0 (a)
              4 LOAD_NAME                1 (b)
              6 CONTAINS_OP              0
              8 RETURN_VALUE

>>> dis.dis('a not in b')
  0           0 RESUME                   0

  1           2 LOAD_NAME                0 (a)
              4 LOAD_NAME                1 (b)
              6 CONTAINS_OP              1
              8 RETURN_VALUE

But if we look at the output of many other operators, we see explicit notation there:

>>> dis.dis('a + b')
  0           0 RESUME                   0

  1           2 LOAD_NAME                0 (a)
              4 LOAD_NAME                1 (b)
              6 BINARY_OP                0 (+)
             10 RETURN_VALUE
>>> dis.dis('a==b')
  0           0 RESUME                   0

  1           2 LOAD_NAME                0 (a)
              4 LOAD_NAME                1 (b)
              6 COMPARE_OP              40 (==)
             10 RETURN_VALUE
             

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@Alexandr153 Alexandr153 added the type-feature A feature request or enhancement label Aug 26, 2024
@sobolevn
Copy link
Member

sobolevn commented Aug 27, 2024

Refs #123340

@Alexandr153 do you want to work on this? :)
I would be happy to help.

@Alexandr153
Copy link
Contributor Author

Refs #123340

@Alexandr153 do you want to work on this? :) I would be happy to help.

Yes, I already tried to modify the module and it worked, but I think it is not the best option. I could look into the code in more detail, with your approval

@sobolevn
Copy link
Member

You can take a look at #123348 It does a very similar thing.

@picnixz picnixz added the stdlib Python modules in the Lib dir label Aug 27, 2024
sobolevn pushed a commit that referenced this issue Aug 28, 2024
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants