How do i share memory between processes?<br><br><b><i>"sjdevnull@yahoo.com" <sjdevnull@yahoo.com></i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> John Henry wrote:<br>> If you're sharing things, I would thread. I would not want to  pay the<br>> expense of a process.<br><br>This is generally a false cost.  There are very few applications where<br>thread/process startup time is at all a fast path, and there are<br>likewise few where the difference in context switching time matters at<br>all.  Indeed, in a Python program on a multiprocessor system, process<br>are potentially faster than threads, not slower.<br><br>Moreover, to get at best a small performance gain you pay a huge cost<br>by sacrificing memory protection within the threaded process.<br><br>You can share things between processes, but you can't memory protect<br>things between threads.  So if you need some of each (some
 things<br>shared and others protected), processes are the clear choice.<br><br>Now, for a few applications threads make sense.  Usually that means<br>applications that have to share a great number of complex data<br>structures (and normally, making the choice for performance reasons<br>means your design is flawed and you could help performance greatly by<br>reworking it--though there may be some exceptions).  But the general<br>rule when choosing between them should be "use processes when you can,<br>and threads when you must".<br><br>Sadly, too many programmers greatly overuse threading.  That problem is<br>exacerbated by the number of beginner-level programming books that talk<br>about how to use threads without ever mentioning processes (and without<br>going into the design of multi-execution apps).<br><br>-- <br>http://mail.python.org/mailman/listinfo/python-list<br></blockquote><br><p> __________________________________________________<br>Do You Yahoo!?<br>Tired
 of spam?  Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com