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: small cleanup #157

Merged
merged 3 commits into from
Jun 11, 2024
Merged

refactor: small cleanup #157

merged 3 commits into from
Jun 11, 2024

Conversation

nstarman
Copy link
Contributor

@nstarman nstarman commented Jun 7, 2024

Slowly adding typing.
This would be good to combine with #147.

Signed-off-by: nstarman <[email protected]>
@coveralls
Copy link

coveralls commented Jun 7, 2024

Pull Request Test Coverage Report for Build 9419751162

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 99.919%

Totals Coverage Status
Change from base Build 9340121872: 0.0%
Covered Lines: 1241
Relevant Lines: 1242

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 7, 2024

Pull Request Test Coverage Report for Build 9419952169

Details

  • 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 99.92%

Totals Coverage Status
Change from base Build 9340121872: 0.001%
Covered Lines: 1246
Relevant Lines: 1247

💛 - Coveralls

Signed-off-by: nstarman <[email protected]>
@coveralls
Copy link

coveralls commented Jun 7, 2024

Pull Request Test Coverage Report for Build 9420047103

Details

  • 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 99.92%

Totals Coverage Status
Change from base Build 9340121872: 0.001%
Covered Lines: 1246
Relevant Lines: 1247

💛 - Coveralls

@nstarman nstarman marked this pull request as ready for review June 7, 2024 16:23
@wesselb
Copy link
Member

wesselb commented Jun 11, 2024

Thanks again for the PR, @nstarman! This change looks good to me.

One question about this: What’s the benefit of making Dispatcher a dataclass c.f. a normal class? Is it that you can set slots, presumably for a performance boost?

@PhilipVinc
Copy link
Collaborator

Slots means a tiny bit less overhead memory. But that does not impact anything we do because that’s sort of a singleton.

I like data classes when they can help make the codec more clear , but in general they are a pain to work with because you lose control over init

‘I’m not sure it’s the best idea to use them here. Though in that particular case it won’t hurt either. But it can add friction for future refactors

@nstarman
Copy link
Contributor Author

nstarman commented Jun 11, 2024

Slots means a tiny bit less overhead memory. But that does not impact anything we do because that’s sort of a singleton.

Only here. Dispatcher is part of the public API and other libraries create their own instances. Adding immutability and reducing memory are both nice additions.

I like data classes when they can help make the codec more clear , but in general they are a pain to work with because you lose control over init …

They reduce boilerplace, add introspection and interop tools (e.g. replace), and they don't relinquish control over __init__ (if an __init__ is defined on a class, not a superclass, @dataclass will not rewrite it).

@wesselb
Copy link
Member

wesselb commented Jun 11, 2024

Thanks for the discussion, both! Since it’s a fairly small change and comes with some benefits (albeit minor ones), I think it’s worthwhile trying to make Dispatcher a dataclass. Should we later decide that we don’t like it after all, because it could make future changes more difficult as @PhilipVinc points out, it would be easy to make Dispatcher a normal class again. Will merge right away! :) Thanks again, @nstarman!

@wesselb wesselb merged commit 6de73bf into beartype:master Jun 11, 2024
7 checks passed
@nstarman nstarman deleted the dispatch-cleanup branch June 11, 2024 17:41
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.

4 participants