Skip to content

CONTAINS_OP can provide the operation name #123363

Closed

Description

@Alexandr153

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

Activity

  1. sobolevn commented on Aug 27, 2024

    @sobolevn
    Member

    Refs #123340

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

  2. Alexandr153 commented on Aug 27, 2024

    @Alexandr153
    ContributorAuthor

    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

  3. sobolevn commented on Aug 27, 2024

    @sobolevn
    Member

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

  4. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Aug 27, 2024
  5. added a commit that references this issue on Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions