Skip to content

gh-119176: Add copy and clear to multiprocessing.ListProxy #119202

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/multiprocessing/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ def set(self, value):
'__add__', '__contains__', '__delitem__', '__getitem__', '__len__',
'__mul__', '__reversed__', '__rmul__', '__setitem__',
'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
'reverse', 'sort', '__imul__'
'reverse', 'sort', '__imul__', 'clear', 'copy',
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better to insert these two new strings between 'append' and 'count', to respect alphabetical order?

))
class ListProxy(BaseListProxy):
def __iadd__(self, value):
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,13 @@ def test_list(self):
a.append('hello')
self.assertEqual(f[0][:], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'hello'])

e2 = e.copy()
self.assertEqual([element[:] for element in e],
[element[:] for element in e2])

e2.clear()
self.assertEqual(e2[:], [])

def test_list_iter(self):
a = self.list(list(range(10)))
it = iter(a)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add ``copy`` and ``clear`` methods support to
``multiprocessing.manager.ListProxy``.
Loading