-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add and implement primitive list.copy() #18771
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
Changes from 8 commits
63d6be9
926a277
d5e7bc1
abd1a04
f1a03bb
eec3dfa
6610e27
32e0130
e74aad5
de725e0
70f3573
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| [case testListCopy] | ||
|
||
| [builtins fixtures/list.pyi] | ||
| def test_list_copy() -> None: | ||
| l1 = [1, 2, 3, -4, 5] | ||
| l2 = l1.copy() | ||
| assert l1.copy() == l1 | ||
| assert l1.copy() == l2 | ||
| assert l1 == l2 | ||
| assert l1.copy() == l2.copy() | ||
| l1 = l2.copy() | ||
| assert l1 == l2 | ||
| assert l1.copy() == l2 | ||
| assert l1 == [1, 2, 3, -4, 5] | ||
| l2 = [1, 2, -3] | ||
| l1 = [] | ||
| assert l1.copy() == [] | ||
| assert l2.copy() != l1 | ||
| assert l2 == l2.copy() | ||
| l1 = l2 | ||
| assert l1.copy().copy() == l2.copy().copy().copy() | ||
| assert l1.copy() == l2.copy() | ||
| l1 == [1, 2, -3].copy() | ||
| assert l1 == l2 | ||
| l2 = [1, 2, 3].copy() | ||
| assert l2 != l1 | ||
| l1 = [1, 2, 3] | ||
| assert l1.copy() == l2.copy() | ||
| l3 = ["string", 2 , 3] | ||
| assert l3 == l3.copy() | ||
| l2 = ["string", 2, 3] | ||
| assert l2 == l3.copy() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| [case testListCopy] | ||
|
||
| [builtins fixtures/list.pyi] | ||
| def test_list_copy() -> None: | ||
| l1 = [1, 2, 3, -4, 5] | ||
| l2 = l1.copy() | ||
| assert l1.copy() == l1 | ||
| assert l1.copy() == l2 | ||
| assert l1 == l2 | ||
| assert l1.copy() == l2.copy() | ||
| l1 = l2.copy() | ||
| assert l1 == l2 | ||
| assert l1.copy() == l2 | ||
| assert l1 == [1, 2, 3, -4, 5] | ||
| l2 = [1, 2, -3] | ||
| l1 = [] | ||
| assert l1.copy() == [] | ||
| assert l2.copy() != l1 | ||
| assert l2 == l2.copy() | ||
| l1 = l2 | ||
| assert l1.copy().copy() == l2.copy().copy().copy() | ||
| assert l1.copy() == l2.copy() | ||
| l1 == [1, 2, -3].copy() | ||
| assert l1 == l2 | ||
| l2 = [1, 2, 3].copy() | ||
| assert l2 != l1 | ||
| l1 = [1, 2, 3] | ||
| assert l1.copy() == l2.copy() | ||
| l3 = ["string", 2 , 3] | ||
| assert l3 == l3.copy() | ||
| l2 = ["string", 2, 3] | ||
| assert l2 == l3.copy() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ class list(Sequence[T]): | |
| def __setitem__(self, x: int, v: T) -> None: pass | ||
| def append(self, x: T) -> None: pass | ||
| def extend(self, x: Iterable[T]) -> None: pass | ||
| def copy(self) -> list[T]: pass | ||
|
||
|
|
||
| class tuple(Generic[T]): pass | ||
| class function: pass | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to get rid of
_PyObject_CallMethodIdNoArgsas it's only an internal method. See #18761 It would be better to usePyObject_CallMethodNoArgshere instead.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Changed method to call PyObject_CallMethodNoArgs