| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I updated the code_richcompare not to modify the code object at all. |
Sorry, something went wrong.
There was a problem hiding this comment.
@markshannon Can you please confirm that this addresses your concern? (I'm sorry it slipped by me when I reviewed the previous PR.)
Sorry, something went wrong.
|
Would it better to ignore co_code_adaptive, and use co_code for comparisons? Ultimately we will want to compare by identity, I think. |
Sorry, something went wrong.
I'm no so sure, I expect that would cause too much breakage. |
Sorry, something went wrong.
Or factor out the normalization code involved in constructing co_code so it can be reused by compare and hash. |
Sorry, something went wrong.
Never mind, that's already factored out (deopt_code()) but it modifies the bytecode array in place. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
IIUC, we need to update _PyCode_CODE for comparisons or add a new macro. It's worth experimenting with it. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM.
Sorry, something went wrong.
It seems pretty fundamental that co == 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 through code.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. |
Sorry, something went wrong.
|
In #101346 I tried to change code objects to compare by identity, and in the process I reached the same conclusion as @gvanrossum. Making co != 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. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.