Skip to content
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

Introduce dict[str, Performance] #511

Merged
merged 5 commits into from
Sep 29, 2022
Merged

Introduce dict[str, Performance] #511

merged 5 commits into from
Sep 29, 2022

Conversation

odashi
Copy link
Contributor

@odashi odashi commented Sep 27, 2022

Related to #491

This PR introduces following changes:

  • Remove metric_name member from Performance.
  • Change all list[Performance] to dict[str, Performance], whose keys are metric names.
  • Refactoring related to these changes.

Originally, metric_name is used as a primary key of the list, and often the list is converted to dict in the library. This change attempts to removes this burden.

bucket_name=bucket_collection.name,
)

performances: dict[str, Performance] = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to require that the performances need to maintain insertion order?

Copy link
Contributor

@neubig neubig Sep 29, 2022

Choose a reason for hiding this comment

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

It would be nice to maintain this property. But it seems that as of Python 3.7, dicts are guaranteed to maintain insertion order: https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think assuming any order is semantically good idea if we are using hashmap (dict) even if the language supports it. If the order of names is meaningful for someone, arranging the order should be the responsibility of callers.

@pfliu-nlp
Copy link
Collaborator

One high-level comment that could be considered as future PRs.

  • refactoring metric_configs, overall and analyses to dict[str, ...] as well

@odashi
Copy link
Contributor Author

odashi commented Sep 29, 2022

One high-level comment that could be considered as future PRs.
refactoring metric_configs, overall and analyses to dict[str, ...] as well

Yes, I am planning to do it. The reason why this PR is proposed first is Performance is the most outer data structure that relies on metric names, and changing any inner structures affects this struct. I will propose other pull requests as well in the outer-inner manner.

@odashi odashi merged commit 98df043 into main Sep 29, 2022
@odashi odashi deleted the dict-performance branch September 29, 2022 19:55
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.

3 participants