FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-101346: compare and hash code objects by identity by carljm · Pull Request #103297 · python/cpython · GitHub

/ cpython Public

gh-101346: compare and hash code objects by identity - #103297

Closed
carljm wants to merge 2 commits into
python:mainfrom
carljm:nohasheq
Closed

gh-101346: compare and hash code objects by identity#103297
carljm wants to merge 2 commits into
python:mainfrom
carljm:nohasheq

Conversation

carljm commented Apr 5, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

This removes the complex, finicky, and unnecessary hash and comparison methods of code objects. As code objects change, these methods regularly become out of date and have to be updated to account for new fields. And as code objects have become more mutable with the specializing interpreter, it makes less sense to treat them as value types.

After this PR, code objects are hashed/equal solely by identity (the default behavior of Python objects), which is faster and simpler.

Given that "naturally occurring" code objects are in practice never equal to each other by the old rules anyway, this only impacts such artificial cases as code == code.replace() (which was previously true and is no longer true with this PR.)

Closes #101346.

carljm closed this Apr 6, 2023

markshannon commented Apr 6, 2023
edited
Loading

Copy link
Copy Markdown
Member

@carljm Did you mean to close this? Just seen your comment on the issue.

carljm commented Apr 6, 2023

Copy link
Copy Markdown
Member Author

@markshannon I did close it intentionally because I become unconvinced we should merge it. But I'm happy to reopen it if we reach a different conclusion.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The hash and equals methods of code objects are large, complex and unnecessary.

3 participants


Back | FazBrowse Home | New Git URL