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

Refactor setter for performance and readability #553

Open
mfisher87 opened this issue Aug 12, 2024 · 0 comments
Open

Refactor setter for performance and readability #553

mfisher87 opened this issue Aug 12, 2024 · 0 comments

Comments

@mfisher87
Copy link
Member

mfisher87 commented Aug 12, 2024

Originally posted by @weiji14 in #550 (comment):

The setter is here:

@params.setter
def params(self, value):
"""
Validate the input list of parameters.
"""
self._params = list(set(self._validate_parameters(value)))

Suggestions:

  1. The code is calling list(set()) twice (once in the setter, and once in _validate_parameters), we could at least remove one of those.
  2. The _valid_params list could be turned into a set for faster membership tests, see https://docs.astral.sh/ruff/rules/literal-membership.
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

No branches or pull requests

1 participant