This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Python 3 support: remove useless var-setting getter
ClosedPublic

Authored by thopre on Sep 21 2019, 10:23 AM.

Details

Summary

Both the ComparisonResult constructor and the stddev_mean getter set
the readonly stddev_mean. While Python 2 accepts it, Python 3 throws
errors (cannot set attribute and infinite recursion respectively). Since
that attribute does not appear to be used anywhere, this commit removes
all this code.

Event Timeline

thopre created this revision.Sep 21 2019, 10:23 AM

Perhaps others are more well-versed in this than I am, but I think that having a link in the commit message and using the terminology used by the documentation ("new-style" and "classic") would be useful here: https://docs.python.org/2/reference/datamodel.html#newstyle. Also, I am not sure that switching these to be new-style classes in Python 2 is necessary. I believe the commit message should give additional rationale, e.g., using new-style classes helps make the Python 2 and Python 3 behaviour of the code more similar.

lnt/server/reporting/analysis.py
109

This seems to work fine if the name of the caching variable and the name of the property is not the same.

114

This makes it possible to assign to the property, which was read-only before this change.

thopre marked 2 inline comments as done.Oct 7 2019, 7:37 AM

Perhaps others are more well-versed in this than I am, but I think that having a link in the commit message and using the terminology used by the documentation ("new-style" and "classic") would be useful here: https://docs.python.org/2/reference/datamodel.html#newstyle. Also, I am not sure that switching these to be new-style classes in Python 2 is necessary. I believe the commit message should give additional rationale, e.g., using new-style classes helps make the Python 2 and Python 3 behaviour of the code more similar.

Good point about terminology. I'm not sure I understand your point about it not being necessary in Python 2. All the changes I'm doing in this Python 3 support series are not necessary for Python 2, they are here to have a codebase that works accross both versions of Python.

Perhaps others are more well-versed in this than I am, but I think that having a link in the commit message and using the terminology used by the documentation ("new-style" and "classic") would be useful here: https://docs.python.org/2/reference/datamodel.html#newstyle. Also, I am not sure that switching these to be new-style classes in Python 2 is necessary. I believe the commit message should give additional rationale, e.g., using new-style classes helps make the Python 2 and Python 3 behaviour of the code more similar.

I hadn't realized that the explicit inheritance from object was not a requirement of Python 3. Therefore as you say it's only to improve behaviour being more similar between Python 2 and 3 but given the timeframe and the low amount of commits on LNT I don't think that is necessary. I think we should make LNT Python 3 only as soon as it can work in that mode, so the less compability code we can add the better. Do you agree with that approach?

thopre updated this revision to Diff 223603.Oct 7 2019, 7:38 AM

Remove class style compability change
Remove stddev_mean property code altogether since it is not used anywhere

I think we should make LNT Python 3 only as soon as it can work in that mode, so the less compability code we can add the better. Do you agree with that approach?

I agree with the approach of minimizing compatibility code. I am not sure about proactively dropping Python 2 support. As you said, the amount of commits going into LNT is low, so keeping Python 2 compatibility once the Python 3 mode works won't cost much development effort.

thopre retitled this revision from [LNT] Python 3 support: make leaf classes inherit from object to [LNT] Python 3 support: remove useless var-setting getter.Oct 7 2019, 12:07 PM
thopre edited the summary of this revision. (Show Details)
thopre added a comment.Oct 7 2019, 2:05 PM

I think we should make LNT Python 3 only as soon as it can work in that mode, so the less compability code we can add the better. Do you agree with that approach?

I agree with the approach of minimizing compatibility code. I am not sure about proactively dropping Python 2 support. As you said, the amount of commits going into LNT is low, so keeping Python 2 compatibility once the Python 3 mode works won't cost much development effort.

It's not so much the development effort rather than the risk of introducing python2- or python3-specific code without noticing. Since LNT is an application so has no problem of reverse dependences and Python 2 becomes EOL in 2 months I feel like a migration allows to quickly remove the compatibility added without much downside. But either way it doesn't impact the amount of effort to migrate so I'm fine with whatever is decided.

This revision is now accepted and ready to land.Oct 9 2019, 6:21 PM
thopre closed this revision.Oct 10 2019, 3:54 AM