gh-140256: Populate argrepr for LOAD_SMALL_INT#140258
gh-140256: Populate argrepr for LOAD_SMALL_INT#140258davep wants to merge 8 commits intopython:mainfrom
argrepr for LOAD_SMALL_INT#140258Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Misc/NEWS.d/next/Library/2025-10-17-15-36-10.gh-issue-140256.FbKByd.rst
Outdated
Show resolved
Hide resolved
|
Code looks good to me. |
|
This fix looks correct, but I doubt about the need of two always equal values in this case. |
|
@efimov-mikhail Are you referring to the output of dis.dis here? Would that now ideally be changed as part of this PR? |
|
Maybe we could add something like this |
|
I do not think that it is useful if we are just repeating the same value. |
In this case, it could be confusing if the argstr looks almost the same. I am also unsure whether it is possible to have that difference except with quoting differences. |
|
Wait. How dou you suggest changing argrepr? because for me even this format is fine actually. I am not even sure that the condition "argrepr != str(self.arg)" would be useful. When does it hold? |
|
Or do you mean to store argrepr but not rendering it? because in this case, I would prefer a generic check saying whether the instruction should have its repr rendered if the value is identical. I am on mobile now so t is hard to check but the check should not be restricted to LOADSMALLINT. What about other instructions that load constants? do they render both their values and args as well? do they have a filled argrepr? (is there another instruction in the first place ?) |
|
@picnixz We discussed this with @efimov-mikhail, and we proposed making this change only for This way, we can backport the PR more easily. |
|
I still don't think this is a relevant change. At best, I agree that
|
Yes, I meant this.
Yes, I propose doing it in follow-up issues and PRs. These are small steps, but I think we can take them one by one. |
|
I prefer we first answer those questions before doing any change in Then we can fill those that need to be filled and hide them in the output in one PR. Because deciding whether to hide the output may also be a generic function that could later be used to determine whether to show those with argvalue == argrepr. |
|
So there's a lot of conversation here but I'm not clear on the conclusion, if there is one. Could someone possibly clearly say what I can do to improve this fix, if anything? |
|
Actually, after reading the code (now that I'm on my laptop), I see that However, We have other places where we do
For instance: class Instruction(_Instruction):
...
@property
def _simplify_repr(self):
return self.baseopcode == LOAD_SMALL_INTand then in the formatter, we would only print the argrepr if |
|
Thanks @picnixz, that's exactly the clarity/summary I was looking for. Very much appreciated. |
|
@davep Is there anything left to do? |
|
@sergey-miryanov I don't believe so. As best as I can tell I took on board the feedback and made the relevant changes. Unless anyone else has any input I think it's good to go from my point of view. |
|
@picnixz Could you please take a look when you have time? |
Closes #140256.
LOAD_SMALL_INThas emptyargreprviaBytecode#140256