Skip to content

Union matches: select type by number of matching fields#264

Open
m-aciek wants to merge 10 commits into
konradhalas:masterfrom
m-aciek:union-matches
Open

Union matches: select type by number of matching fields#264
m-aciek wants to merge 10 commits into
konradhalas:masterfrom
m-aciek:union-matches

Conversation

@m-aciek

@m-aciek m-aciek commented Oct 22, 2024

Copy link
Copy Markdown
Contributor

Closes #263.

@airunderscoreland airunderscoreland left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it safely solves the issue

@m-aciek

m-aciek commented Oct 23, 2024

Copy link
Copy Markdown
Contributor Author

There was an unintended bug in my code. I fixed it with 39d01b7.

Python default sorting is ascending and I wanted to get a quotient of sets. The test passed by accident.

1 {'j'}  # I was getting this element
2 {'i', 'j'}

0 set()
1 {'j'}  # after 39d01b7 (fix) I'm getting this (same element, but the logic is fixed)

@mciszczon

Copy link
Copy Markdown
Collaborator

@m-aciek I'd say this is not a minor change, as it changes the internal behavior of the library: from "match first" to "match best"—which also might not be a trivial thing to say what it means that one structure matches best and not the other.

I could envision this new behavior as an opt-in feature, i.e. union_deep_match=True somewhere to enable deep processing of unions. This would come with a performance hit as well, I believe.

So my proposed solution is:

  • implement this deep union matching behind an opt-in flag
  • ensure dacite behaves same way as before if no flag is set
  • create extensive test suites to cover the new functionality and ensure no incidental breaking changes
  • add performance tests to track the performance of deep union matching

I know it's quite a lot and would love to help, but struggle to find the time. Would you be willing to try to add/finish all of the pieces described above?

@m-aciek

m-aciek commented Oct 23, 2025

Copy link
Copy Markdown
Contributor Author

Thank you for the answer.

  • add performance tests to track the performance of deep union matching

Do you have some guidelines for the performance tests? How could they look like?

I know it's quite a lot and would love to help, but struggle to find the time. Would you be willing to try to add/finish all of the pieces described above?

I am willing, but also am short with time. Will try to get to it at some point in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When parsing with Union Optional values are swallowing the input

3 participants