This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: dataclasses: generate the _hash_action table from the if-else tree
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: eric.smith, iomintz, rhettinger
Priority: normal Keywords:

Created on 2019-10-03 23:04 by iomintz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16547 closed iomintz, 2019-10-03 23:04
Messages (4)
msg353887 - (view) Author: Io Mintz (iomintz) * Date: 2019-10-03 23:04
The dataclasses._hash_action table is currently a bit hard to read. It could be generated once from the if-else tree written in instead, which would both be easier to read and easier to maintain, while still maintaining the efficiency of the current dictionary.
msg353888 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-10-03 23:35
I don't see that as an improvement, especially when the goal is to not change any functionality.

But maybe I'm just used to truth tables. To me, the truth table makes it clear that each case is handled correctly.
msg353899 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-10-04 06:39
I concur with Eric.  The original code is preferable.
msg353920 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-10-04 11:24
Thank you for your contribution, @iomintz, but I'm not going to accept this change. I don't think it improves the clarity of the code. And I realize this is wholly a subjective decision, and others may disagree. But to me, looking at the table it's clear that each case is handled correctly, while looking through the code I'd need to reason about it for each case.
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82547
2019-10-04 11:24:32eric.smithsetstatus: open -> closed
resolution: rejected
messages: + msg353920

stage: resolved
2019-10-04 06:39:44rhettingersetnosy: + rhettinger
messages: + msg353899
2019-10-03 23:35:27eric.smithsetassignee: eric.smith

messages: + msg353888
nosy: + eric.smith
2019-10-03 23:04:49iomintzcreate