Skip to content

Use normal list constructor in List.__new__() - #7257

Merged
sklam merged 1 commit into
numba:masterfrom
gmarkall:pr-7251-followup
Aug 2, 2021
Merged

sklam merged 1 commit into
numba:masterfrom
gmarkall:pr-7251-followup

Conversation

@gmarkall

Copy link
Copy Markdown
Member

Calling list.__new__() without arguments and then list.__init__() with arguments on the resulting object is not guaranteed to work - the fact that list.__new__() doesn't refer to its arguments (and therefore doesn't strictly require them to be the same as the arguments to __init__()) is an implementation detail.

It is safer to just call list(*args, **kwargs) instead.

With thanks to @eric-wieser (ref: #7251 (comment))

Calling `list.__new__()` without arguments and then `list.__init__()`
with arguments on the resulting object is not guaranteed to work - the
fact that `list.__new__()` doesn't refer to its arguments (and therefore
doesn't strictly require them to be the same as the arguments to
`__init__()`) is an implementation detail.

It is safer to just call `list(*args, **kwargs)` instead.

@esc esc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you for the patch @gmarkall -- thank you for the review @eric-wieser !

@gmarkall gmarkall added the 5 - Ready to merge Review and testing done, is ready to merge label Jul 28, 2021
@sklam sklam added this to the Numba 0.55 RC milestone Aug 2, 2021
@sklam
sklam merged commit 07975e6 into numba:master Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Review and testing done, is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants