<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 11, 2016 at 5:39 AM, Matěj  Týč <span dir="ltr"><<a href="mailto:matej.tyc@gmail.com" target="_blank">matej.tyc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">* ... I do see some value in providing a canonical right way to<br>
construct shared memory arrays in NumPy, but I'm not very happy with<br>
this solution, ... terrible code organization (with the global<br>
variables):<br>
* I understand that, however this is a pattern of Python<br>
multiprocessing and everybody who wants to use the Pool and shared<br>
data either is familiar with this approach or has to become familiar<br>
with[2, 3]. The good compromise is to have a separate module for each<br>
parallel calculation, so global variables are not a problem.<br></blockquote><div><br></div></div></div><div class="gmail_extra"><div>OK, we can agree to disagree on this one. I still don't think I could get code using this pattern checked in at my work (for good reason).</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">* If there's some way to we can paper over the boilerplate such that<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">users can use it without understanding the arcana of multiprocessing,<br>then yes, that would be great. But otherwise I'm not sure there's<br>anything to be gained by putting it in a library rather than referring<br>users to the examples on StackOverflow [1] [2].<br>* What about telling users: "You can use numpy with multiprocessing.<br>Remeber the multiprocessing.Value and multiprocessing.Aray classes?<br>numpy.shm works exactly the same way, which means that it shares their<br>limitations. Refer to an example: <link to numpy doc>." Notice that<br>although those SO links contain all of the information, it is very<br>difficult to get it up and running for a newcomer like me few years<br>ago.<br></blockquote><div><br></div><div>I guess I'm still not convinced this is the best we can with the multiprocessing library. If we're going to do this, then we definitely need to have the fully canonical example.</div><div><br></div><div>For example, could you make the shared array a global variable and then still pass references to functions called by the processes anyways? The examples on stackoverflow that we're both looking are varied enough that it's not obvious to me that this is as good as it gets.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">* This needs tests and justification for custom pickling methods,<br>which are not used in any of the current examples. ...<br>* I am sorry, but don't fully understand that point. The custom<br>pickling method of shmarray has to be there on Windows, but users<br>don't have to know about it at all. As noted earlier, the global<br>variable is the only way of using standard Python multiprocessing.Pool<br>with shared objects.<br></blockquote><div><br></div><div>That sounds like a fine justification, but given that it wasn't obvious you needs a comment saying as much in the source code :). Also, it breaks pickle, which is another limitation that needs to be documented.</div></div></div>