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

obj = object.__new__(cls) #57

Closed
czgdp1807 opened this issue Dec 21, 2019 · 4 comments · Fixed by #63
Closed

obj = object.__new__(cls) #57

czgdp1807 opened this issue Dec 21, 2019 · 4 comments · Fixed by #63

Comments

@czgdp1807
Copy link
Member

Description of the problem

Currently any class object is created by,

obj = object.__new__(cls)

For better readability, each such line should be replaced by the abstract superclass of that class.
Something like,

obj = <name_of_abstract_super_class>.__new__(cls)

For example, in arrays.py, OneDimensionalArray is created by,


However, the above should be replaced by,

obj = Array.__new__(cls)

Example of the problem

References/Other comments

@alpeshjamgade
Copy link

hey, i would like to work on this.

@czgdp1807
Copy link
Member Author

Thanks for the interest. You can start working on it.

@TarunTomar122
Copy link
Contributor

For all the classes that are inheriting from superclass Object this line should remain the same, Isn't it?

@czgdp1807
Copy link
Member Author

czgdp1807 commented Dec 23, 2019

@TarunTomar122 Yes, if class S(provided it shouldn't be object, :-)) is the class at the topmost level in the inheritance hierarchy then any child C below S in the hierarchy should create its objects something like,

def __new__(cls, ...):
    obj = S.__new__(cls)
    ...
    return obj

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

Successfully merging a pull request may close this issue.

3 participants