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

Why does __init__ exist? #239

Closed
spacether opened this issue Jul 5, 2023 · 5 comments
Closed

Why does __init__ exist? #239

spacether opened this issue Jul 5, 2023 · 5 comments

Comments

@spacether
Copy link
Contributor

spacether commented Jul 5, 2023

Why does __init__ exist for this class?
Should an immutable class do all setup in __new__ and not need to invoke __init__ at all?
My understanding is that yes it should.
For example tuple does not need to invoke init to return back the fully formed instance, it only needs new.

How about moving the __init__ setup into the __new__ method and releasing a new major version with the update?
Hmm doing that might require that the class inherit from tuple or namedtuple to be able to store the hash and dict with type hints.

@corenting
Copy link
Owner

Hello ! Thanks for reporting the issue.
The init code was not changed since the original frozendict, I will see if it can be improved without impacting the usage and the typing.

@spacether
Copy link
Contributor Author

spacether commented Sep 13, 2023

@corenting the PR that I created on your repo will resolve this issue if merged. When you have some time can you review it?

@corenting
Copy link
Owner

Sorry for the late answer and thanks for the MR ! I will try to take some time to review it

@corenting
Copy link
Owner

The MR was merged, thanks again. Closing the issue at will be included in the next release.

@spacether
Copy link
Contributor Author

Thanks for the merge!

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

2 participants