-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Revert "GH-96145: Add AttrDict to JSON module for use with object_hook (#96146)" #105948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ct_hook (python#96146)" This reverts commit 1f0eafa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not against the concept, it sounds appealing. But it seems like the implementation has some issues and deserves to be discussed. Maybe it was too early to put it in Python 3.12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for this revert.
Please elaborate. This is the simplest possible implementation that meets the spec of being fully substitutable for a regular dict while allowing optional attribute access for all valid identifiers that aren't keywords or dict methods. The implementation is pretty much unchanged since introduced by Martelli twenty years ago and is the usual recipe that people have been using in practice. While it is possible to contrive a funky case like Jelle's I would support marking this as provisional to leave wiggle room for dealing with Jelle's We've already has two decades of people reinventing this for the own projects, so it is not doing to mature much from here. Also, the people like CAM Gerlack who fundamentally oppose this programming practice data will likely never change their minds despite the successes of dataclasses, SimpleNamespace, and argparse.Namespace. ISTM those folks have never personally felt the pain of using chains of square brackets and quotes for lookups into known schemas, nor suffered the consequent readability issues (but acknowledge that I can't really know what is in their minds). I vote for shipping it as-is, or perhaps marking this a provisional , or perhaps adding a note that the handling of |
@JelleZijlstra Would this minor edit satisfy your concern about the
The net result is that |
As RM, can I please ask that we not iterate on design right before the final beta release? We'd have one chance to get it exactly right, and regardless of my own opinion on the suitability of the feature, I don't want to deal with the fallout of getting this wrong. |
GH-106117 is a backport of this pull request to the 3.12 branch. |
…ct_hook (pythonGH-96146)" (pythonGH-105948) This reverts commit 1f0eafa. (cherry picked from commit d3af83b) Co-authored-by: Łukasz Langa <[email protected]>
This reverts commit 1f0eafa.
More discussion on the issue.
📚 Documentation preview 📚: https://cpython-previews--105948.org.readthedocs.build/