Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-103134: Update multiprocessing.managers.ListProxy and multiprocessing.managers.DictProxy #103133
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6fb4cbab3c8810fc803caa748d4122de5a18602f0a6fe264a8c2afdb3ae57491cf09855ef9850dd54efc8354c5bb826c7b8550fe6a57c395d3e88afdc298c6e33e7ab9e71823847c072820b45be94d306083ad3d83ecdb36f2ea5bb95f8400e94e3115089ced9b3bf69eb39c980a2f64577e5a372d1055File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1152,10 +1152,10 @@ def set(self, value): | ||
| BaseListProxy = MakeProxyType('BaseListProxy', ( | ||
| '__add__', '__contains__', '__delitem__', '__getitem__', '__len__', | ||
| '__mul__', '__reversed__', '__rmul__', '__setitem__', | ||
| 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', | ||
| 'reverse', 'sort', '__imul__' | ||
| '__add__', '__contains__', '__delitem__', '__getitem__', '__imul__', | ||
| '__len__', '__mul__', '__reversed__', '__rmul__', '__setitem__', | ||
| 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', | ||
| 'remove', 'reverse', 'sort', | ||
| )) | ||
| class ListProxy(BaseListProxy): | ||
| def __iadd__(self, value): | ||
| @@ -1169,16 +1169,20 @@ def __imul__(self, value): | ||
| _BaseDictProxy = MakeProxyType('DictProxy', ( | ||
| '__contains__', '__delitem__', '__getitem__', '__iter__', '__len__', | ||
| '__setitem__', 'clear', 'copy', 'get', 'items', | ||
| '__contains__', '__delitem__', '__getitem__', '__ior__', '__iter__', | ||
invisibleroads marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| '__len__', '__or__', '__reversed__', '__ror__', | ||
| '__setitem__', 'clear', 'copy', 'fromkeys', 'get', 'items', | ||
| 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values' | ||
| )) | ||
| _BaseDictProxy._method_to_typeid_ = { | ||
| '__iter__': 'Iterator', | ||
| } | ||
| class DictProxy(_BaseDictProxy): | ||
| __class_getitem__ = classmethod(types.GenericAlias) | ||
| def __ior__(self, value): | ||
| self._callmethod('__ior__', (value,)) | ||
| return self | ||
| __class_getitem__ = classmethod(types.GenericAlias) | ||
| ArrayProxy = MakeProxyType('ArrayProxy', ( | ||
| '__len__', '__getitem__', '__setitem__' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -6064,12 +6064,30 @@ def _test_list(cls, obj): | ||
| case.assertEqual(obj[0], 5) | ||
| case.assertEqual(obj.count(5), 1) | ||
| case.assertEqual(obj.index(5), 0) | ||
| obj += [7] | ||
invisibleroads marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| case.assertIsInstance(obj, multiprocessing.managers.ListProxy) | ||
| case.assertListEqual(list(obj), [5, 7]) | ||
| obj *= 2 | ||
| case.assertIsInstance(obj, multiprocessing.managers.ListProxy) | ||
| case.assertListEqual(list(obj), [5, 7, 5, 7]) | ||
| double_obj = obj * 2 | ||
| case.assertIsInstance(double_obj, list) | ||
| case.assertListEqual(list(double_obj), [5, 7, 5, 7, 5, 7, 5, 7]) | ||
| double_obj = 2 * obj | ||
| case.assertIsInstance(double_obj, list) | ||
| case.assertListEqual(list(double_obj), [5, 7, 5, 7, 5, 7, 5, 7]) | ||
| copied_obj = obj.copy() | ||
| case.assertIsInstance(copied_obj, list) | ||
| case.assertListEqual(list(copied_obj), [5, 7, 5, 7]) | ||
| obj.extend(double_obj + copied_obj) | ||
| obj.sort() | ||
| obj.reverse() | ||
| for x in obj: | ||
| pass | ||
| case.assertEqual(len(obj), 1) | ||
| case.assertEqual(obj.pop(0), 5) | ||
| case.assertEqual(len(obj), 16) | ||
| case.assertEqual(obj.pop(0), 7) | ||
| obj.clear() | ||
| case.assertEqual(len(obj), 0) | ||
| def test_list(self): | ||
| o = self.manager.list() | ||
| @@ -6088,7 +6106,29 @@ def _test_dict(cls, obj): | ||
| case.assertListEqual(list(obj.keys()), ['foo']) | ||
| case.assertListEqual(list(obj.values()), [5]) | ||
| case.assertDictEqual(obj.copy(), {'foo': 5}) | ||
| case.assertTupleEqual(obj.popitem(), ('foo', 5)) | ||
| obj |= {'bar': 6} | ||
invisibleroads marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| case.assertIsInstance(obj, multiprocessing.managers.DictProxy) | ||
| case.assertDictEqual(dict(obj), {'foo': 5, 'bar': 6}) | ||
| x = reversed(obj) | ||
| case.assertIsInstance(x, type(iter([]))) | ||
| case.assertListEqual(list(x), ['bar', 'foo']) | ||
| x = {'bar': 7, 'baz': 7} | obj | ||
| case.assertIsInstance(x, dict) | ||
| case.assertDictEqual(dict(x), {'foo': 5, 'bar': 6, 'baz': 7}) | ||
| x = obj | {'bar': 7, 'baz': 7} | ||
| case.assertIsInstance(x, dict) | ||
| case.assertDictEqual(dict(x), {'foo': 5, 'bar': 7, 'baz': 7}) | ||
| x = obj.fromkeys(['bar'], 6) | ||
| case.assertIsInstance(x, dict) | ||
| case.assertDictEqual(x, {'bar': 6}) | ||
| x = obj.popitem() | ||
| case.assertIsInstance(x, tuple) | ||
| case.assertTupleEqual(x, ('bar', 6)) | ||
| obj.setdefault('bar', 0) | ||
| obj.update({'bar': 7}) | ||
| case.assertEqual(obj.pop('bar'), 7) | ||
| obj.clear() | ||
| case.assertEqual(len(obj), 0) | ||
| def test_dict(self): | ||
| o = self.manager.dict() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Add additional methods to :ref:`proxy objects <multiprocessing-proxy_objects>` | ||
| in the :mod:`!multiprocessing` module: | ||
| * :meth:`!clear` and :meth:`!copy` for proxies of :class:`list` | ||
| * :meth:`~dict.fromkeys`, ``reversed(d)``, ``d | {}``, ``{} | d``, | ||
| ``d |= {'b': 2}`` for proxies of :class:`dict` |
Uh oh!
There was an error while loading. Please reload this page.