Message365213
| Author |
serhiy.storchaka |
| Recipients |
Julian, Philip Dye, anthony shaw, anthonypjshaw, benjamin.peterson, levkivskyi, louielu, serhiy.storchaka |
| Date |
2020年03月28日.14:46:53 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1585406814.54.0.821955725136.issue15987@roundup.psfhosted.org> |
| In-reply-to |
| Content |
I am not sure that implementing a rich comparison of AST nodes is the right way. There are too much options (compare attributes or not, compare recursively or not, compare types or not) and __eq__ does not support options. In addition, it requires implementing compatible __hash__, but how do you implement a hash of mutable object? In addition, recursive comparison can introduce a regression in existing code -- instead of fast returning False the comparison will spent a nontrivial amount of time.
If implement a comparison of AST nodes, it should be a separate function which support multiple options. Would be nice also to have examples where this feature can be used before implementing it.
See also issue37792. |
|