KEMBAR78
GH-100923: Embed jump mask in `COMPARE_OP` oparg by markshannon · Pull Request #100924 · python/cpython · GitHub
Skip to content

Conversation

@markshannon
Copy link
Member

@markshannon markshannon commented Jan 10, 2023

@markshannon markshannon changed the title Embed jump mask in COMPARE_OP oparg GH-100923: Embed jump mask in COMPARE_OP oparg Jan 10, 2023
@sweeneyde
Copy link
Member

Can the mask be added at compile time to avoid mutating the logical code?

def f():
    ...
c0 = f.__code__.replace()
# ... run the code here ...
c1 = f.__code__

assert c0 == c1              # fails?
assert hash(c0) == hash(c1)  # fails?

@sweeneyde
Copy link
Member

Oh I see, the work is being done in PyCode_Quicken, which is already called on every code object, so we should be okay.

@markshannon
Copy link
Member Author

Yes, the plan is to move PyCode_Quicken into the compiler. faster-cpython/ideas#530

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
@markshannon markshannon merged commit 6e4e14d into python:main Jan 11, 2023
@markshannon markshannon deleted the embed-mask-in-compare-oparg branch January 11, 2023 21:00
@esc
Copy link
Contributor

esc commented Sep 25, 2023

I just stumbled upon this. It seems like this PR didn't update the docs, as:

https://docs.python.org/3.12/library/dis.html#opcode-COMPARE_OP

Reads:

Screenshot 2023-09-25 at 18 24 05

Perhaps the new masking mechanism could be included here? Or maybe it will suffice to update the docs to say cmp_op[opname>>4]? Would be happy to try to submit a PR if that is welcome.

@brandtbucher
Copy link
Member

That issue is being covered in #107457.

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

Successfully merging this pull request may close these issues.

6 participants