Skip to content

CONTAINS_OP can provide the operation name #123363

Closed
@Alexandr153

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions