From c2142aa2e605d156b98bec60537cbfcf19e7f0b5 Mon Sep 17 00:00:00 2001 From: Tom Kelley Date: Tue, 3 Oct 2023 10:52:09 -0700 Subject: [PATCH 1/5] Add SynchronizedBase to __all__ Recently I was writing some heavily-parallel code, and I tried to type-check with `mypy`. I (naively) thought that `multiprocessing.Value` was a class and was very confused when `mypy` threw an error on that line. I dropped into the interpreter and tried to use the `help` function to find the return type of `Value` - and failed. I dropped into the code and found that the type returned from the `Value` function was not exported from the module. I want types in Python to be _awesome_. I think `mypy` is a step in the right direction for that. This change is me doing my part to expose more types so `mypy` can become as good as it can be. distortedsignal --- Lib/multiprocessing/sharedctypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/multiprocessing/sharedctypes.py b/Lib/multiprocessing/sharedctypes.py index 6071707027bea4..9c6cf3e4fb4706 100644 --- a/Lib/multiprocessing/sharedctypes.py +++ b/Lib/multiprocessing/sharedctypes.py @@ -16,7 +16,7 @@ from .context import reduction, assert_spawning _ForkingPickler = reduction.ForkingPickler -__all__ = ['RawValue', 'RawArray', 'Value', 'Array', 'copy', 'synchronized'] +__all__ = ['RawValue', 'RawArray', 'Value', 'Array', 'copy', 'synchronized', 'SynchronizedBase'] # # From 90d56fc89f85715a1bb71cf815bea8c500ea7f2d Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:59:01 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst diff --git a/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst b/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst new file mode 100644 index 00000000000000..2e2d391fa3b74c --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst @@ -0,0 +1 @@ +Export the base synchronization class so multiprocessing users can typecheck their code. From a56ea72e9c54f785775d141d94f53273fb249ba0 Mon Sep 17 00:00:00 2001 From: Tom Kelley Date: Tue, 3 Oct 2023 11:10:09 -0700 Subject: [PATCH 3/5] ReST-format NEWS.d --- .../Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst b/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst index 2e2d391fa3b74c..4a0c1a147936f1 100644 --- a/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst +++ b/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst @@ -1 +1,2 @@ -Export the base synchronization class so multiprocessing users can typecheck their code. +Export :class:`multiprocessing.SynchronizedBase` so multiprocessing users can +typecheck their code. From 3bbcab6bd906a34190d6773de7a877a2c72ddc10 Mon Sep 17 00:00:00 2001 From: Tom Kelley Date: Tue, 3 Oct 2023 11:44:43 -0700 Subject: [PATCH 4/5] SynchronizedBase isn't as helpful as I thought. --- Lib/multiprocessing/sharedctypes.py | 11 ++++++++++- .../2023-10-03-17-59-00.gh-issue-0.m1D01N.rst | 6 ++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Lib/multiprocessing/sharedctypes.py b/Lib/multiprocessing/sharedctypes.py index 9c6cf3e4fb4706..58c8ff7680ee65 100644 --- a/Lib/multiprocessing/sharedctypes.py +++ b/Lib/multiprocessing/sharedctypes.py @@ -16,7 +16,16 @@ from .context import reduction, assert_spawning _ForkingPickler = reduction.ForkingPickler -__all__ = ['RawValue', 'RawArray', 'Value', 'Array', 'copy', 'synchronized', 'SynchronizedBase'] +__all__ = [ + # Methods for getting ctypes in shared memory + 'RawValue', 'RawArray', + # Methods for getting synchronization wrappers + 'Value', 'Array', + # The synchronization types + 'Synchronized', 'SynchronizedArray', 'SynchronizedString', + # Misc functions + 'copy', 'synchronized' +] # # diff --git a/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst b/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst index 4a0c1a147936f1..d2a9c45c3ca1dd 100644 --- a/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst +++ b/Misc/NEWS.d/next/Documentation/2023-10-03-17-59-00.gh-issue-0.m1D01N.rst @@ -1,2 +1,4 @@ -Export :class:`multiprocessing.SynchronizedBase` so multiprocessing users can -typecheck their code. +Export :class:`multiprocessing.Synchronized`, +:class:`multiprocessing.SynchronizedArray`, and +:class:`multiprocessing.SynchronizedString` so multiprocessing users can +annotate their code well. From b58403ea36e32477b392e9d50d43167b230c15dc Mon Sep 17 00:00:00 2001 From: Tom Kelley Date: Tue, 3 Oct 2023 11:49:03 -0700 Subject: [PATCH 5/5] Standardize brackets. --- Lib/multiprocessing/sharedctypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/multiprocessing/sharedctypes.py b/Lib/multiprocessing/sharedctypes.py index 58c8ff7680ee65..3290246b31431f 100644 --- a/Lib/multiprocessing/sharedctypes.py +++ b/Lib/multiprocessing/sharedctypes.py @@ -25,7 +25,7 @@ 'Synchronized', 'SynchronizedArray', 'SynchronizedString', # Misc functions 'copy', 'synchronized' -] + ] # # pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy