Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-107265: Fix code_hash for ENTER_EXECUTOR case#108188

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gvanrossum merged 7 commits intopython:mainfromcorona10:gh-107265-hash
Aug 21, 2023

Conversation

corona10
Copy link
Member

@corona10corona10 commentedAug 21, 2023
edited by bedevere-bot
Loading

@corona10
Copy link
MemberAuthor

corona10 commentedAug 21, 2023
edited
Loading

@gvanrossum cc@markshannon

I updated the code_richcompare not to modify the code object at all.

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@markshannon Can you please confirm that this addresses your concern? (I'm sorry it slipped by me when I reviewed the previous PR.)

@markshannon
Copy link
Member

Would it better to ignoreco_code_adaptive, and useco_code for comparisons?
It will definitely be slower, but it will be correct.

Ultimately we will want to compare by identity, I think.

@gvanrossum
Copy link
Member

Ultimately we will want to compare by identity, I think.

I'm no so sure, I expect that would cause too much breakage.

@gvanrossum
Copy link
Member

Would it better to ignoreco_code_adaptive, and useco_code for comparisons?

Or factor out the normalization code involved in constructingco_code so it can be reused by compare and hash.

@gvanrossum
Copy link
Member

Would it better to ignoreco_code_adaptive, and useco_code for comparisons?

Or factor out the normalization code involved in constructingco_code so it can be reused by compare and hash.

Never mind, that's already factored out (deopt_code()) but it modifies the bytecode array in place.

@markshannon
Copy link
Member

We keep changing the hash and equality functions, so I don't really see how another change will break anything, apart from assumptions in the compiler.

@corona10
Copy link
MemberAuthor

corona10 commentedAug 21, 2023
edited
Loading

Would it better to ignore co_code_adaptive, and use co_code for comparisons?
It will definitely be slower, but it will be correct.

IIUC, we need to update _PyCode_CODE for comparisons or add a new macro. It's worth experimenting with it.
I would like to do it in separate PR including the performance overhead comparison.

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM.

@gvanrossum
Copy link
Member

We keep changing the hash and equality functions, so I don't really see how another change will break anything, apart from assumptions in the compiler.

It seems pretty fundamental thatco == co.replace(), which comparing by identity would break (and we rely in many places on.replace() always creating a new code object, with no specializations or executors, and all caches reset). IMO any field that can be changed throughcode.replace(xxx=yyy) should be included in equality, and no others. The hash should use a pragmatic subset of these that satisfies the required relationship between hash and equality and can be computed quickly.

corona10 and carljm reacted with thumbs up emoji

@carljm
Copy link
Member

carljm commentedAug 21, 2023
edited
Loading

In#101346 I tried to change code objects to compare by identity, and in the process Ireached the same conclusion as@gvanrossum.

Makingco != co.replace() (or, similarly,compile(source_string, ...) != compile(source_string, ...)) is a much bigger change than any tweaks to the details of code object comparison that have happened up until now.

@gvanrossumgvanrossum merged commite6db23f intopython:mainAug 21, 2023
@corona10corona10 deleted the gh-107265-hash branchAugust 21, 2023 23:29
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gvanrossumgvanrossumgvanrossum approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@corona10@markshannon@gvanrossum@carljm@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp