Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.045 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'cpython': 0.05; 'binary': 0.07; 'works.': 0.09; 'did.': 0.16; 'finer': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'heap,': 0.16; 'simplified': 0.16; 'subject:recursion': 0.16; 'variables,': 0.16; 'prevent': 0.16; 'language': 0.16; 'wrote:': 0.18; 'figures': 0.19; 'saying': 0.22; 'separate': 0.22; 'subject:problem': 0.24; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'message-id:@mail.gmail.com': 0.30; 'went': 0.31; 'operations.': 0.31; "they'll": 0.31; 'though.': 0.31; 'run': 0.32; 'running': 0.33; 'sense': 0.34; 'subject:the': 0.34; 'problem': 0.35; "can't": 0.35; 'received:209.85': 0.35; 'except': 0.35; 'received:209.85.220': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'should': 0.36; 'example,': 0.37; 'two': 0.37; 'received:209': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'ian': 0.60; 'new': 0.61; "you're": 0.61; 'complete': 0.62; 'different': 0.65; '26,': 0.68; 'analysis': 0.75; 'potentially': 0.81; 'atomic': 0.84; 'choices.': 0.84; 'thing,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=8DppWbkzjzI7zfAPhVBnL5UiytYNpAinriisyIoW55g=; b=ZkRwZ91hOa+SxKJEUQPteDfhbL84oh7/g6gFyzcIY+G+DKl0ghBIPxaFW1v+W3mfjI MQZS16ZRNSl6mbRgLTepr5UHt+xh35NIFzHrlyhZyQQWuwQtvMzqDm9UbwmJasa3N+eY 9cGl7Ix0vEPk3GgEsmyxcWR1WCS6RTb1RomjEGcuKrWg6CuMFnjw9cwpXc+SfQ6s6BDn +01JQ2SBPGu+UkMMdm724HvRM0mXV8TFqRXtESPnVKX8OqHjOyIea3TqZfoPozedD9Q2 dcBXMHo6OnSEMWKBQwd0wG4P56RKc+XGjith2l7TAycQEucQAKNm22Ij6j3RlVOyNMj4 Yxbw== MIME-Version: 1.0 X-Received: by 10.220.215.73 with SMTP id hd9mr7537489vcb.19.1369640241244; Mon, 27 May 2013 00:37:21 -0700 (PDT) In-Reply-To: References: <55942e65-e4a5-45fc-b2fc-ceb4020959dd@k4g2000vba.googlegroups.com> <074eac8a-1bc4-4fe0-afa9-1f52405f81d5@k3g2000vbn.googlegroups.com> <9890fd93-fd9b-4865-a01e-4cd1d558d5fc@w15g2000vbn.googlegroups.com> Date: Mon, 27 May 2013 17:37:21 +1000 Subject: Re: Solving the problem of mutual recursion From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369640244 news.xs4all.nl 15959 [2001:888:2000:d::a6]:54044 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46178 On Mon, May 27, 2013 at 4:07 PM, Ian Kelly wrote: > On Sun, May 26, 2013 at 10:36 PM, Peter Brooks > wrote: >> This makes complete sense - any atomic action should be atomic, so two >> threads can't be doing it at the same time. They can be doing anything >> else though. >> >> If two threads create a new object at the same time, for example, >> there's potentially the problem that they'll get the same space, so >> the object will be owned by both. To prevent this, the new object call >> should be run in only one thread. >> >> If you have two objects running their methods on their own local >> variables, then there's no potential for conflict, so there's no need >> for them to be blocked. > > That's not the way it works. [snip details] You're actually both saying the same thing, except that Peter went for finer granularity than Ian and CPython did. CPython figures that, with a refcounted heap, there's not a lot of point having separate mutex locks for different operations. Other language interpreters have made other choices. But Peter's analysis is still correct; it's just that guarding it is simplified down to a binary state: either you have the GIL, or you don't. ChrisA