-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(python): improve large Enum reprs #13357
base: main
Are you sure you want to change the base?
feat(python): improve large Enum reprs #13357
Conversation
Are we dependent on that? I don't think we should. Repr and serde a different things. |
I entirely agree ;) |
c3d65aa
to
0965770
Compare
Ai.. Doesn't pickle work out of the box? |
It does, but you don't want pickle if your interop is via JSON (like patito) or you are serialising more generally. I figure we probably need a |
Random idea: can we have a I think that could address the situation adequately (repr can be eval'd, printing the object gets a compact result). EDIT: I worked out the idea a bit further: #13439 |
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 think we should go ahead with this, but first implement serialization as requested in #13152
0965770
to
8255cc2
Compare
8255cc2
to
2a8aa0e
Compare
2a8aa0e
to
e40c122
Compare
e40c122
to
12a1ef4
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #13357 +/- ##
==========================================
- Coverage 81.22% 81.02% -0.21%
==========================================
Files 1348 1332 -16
Lines 175333 172883 -2450
Branches 2508 2461 -47
==========================================
- Hits 142420 140075 -2345
+ Misses 32433 32340 -93
+ Partials 480 468 -12 ☔ View full report in Codecov by Sentry. |
12a1ef4
to
be0033a
Compare
be0033a
to
fc48302
Compare
Closes #13337.
Split-out from #13345 following some insight from @stinodego, and contains only the improved
__repr__
.Examples
Improved repr for Enum with a large number of categories:
ℹ️ RFC: DataType serialisation
Parked this PR in Draft as there is apparently an implicit expectation that the DataType repr should be guaranteed to eval back to the equivalent instantiated object, acting as a form of serialisation. I think we need a real API point for this instead, as the repr is a fragile/non-standard way to handle that, and not obvious.
Given the desired use-case1 I think we might want to add
write_json
andfrom_json
methods for DataType, which would decouple serialisation from the repr and offer a solid/consistent API for this use-case. We already have such methods available for Expr, for example.Footnotes
See Implement
DataType.serialize/deserialize
for serializing to/from JSON #13152 ↩