Re: Solving the problem of mutual recursion

2013-05-27 Thread Ian Kelly
On Sun, May 26, 2013 at 10:36 PM, Peter Brooks peter.h.m.bro...@gmail.com 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

Re: Solving the problem of mutual recursion

2013-05-27 Thread Ian Kelly
On Sun, May 26, 2013 at 4:16 PM, Chris Angelico ros...@gmail.com wrote: On Mon, May 27, 2013 at 5:35 AM, Ian Kelly ian.g.ke...@gmail.com wrote: I'm pretty sure that CPython uses the GIL regardless of platform. And yes you can have multiple OS-level threads, but because of the GIL only one

Re: Solving the problem of mutual recursion

2013-05-27 Thread Ian Kelly
On Mon, May 27, 2013 at 12:19 AM, Ian Kelly ian.g.ke...@gmail.com wrote: 7) Since the program being tested does basically nothing except start and exit threads, the extra 40% probably represents the overhead of all that starting and stopping, which would be done outside the GIL. To test this,

Re: Solving the problem of mutual recursion

2013-05-27 Thread Chris Angelico
On Mon, May 27, 2013 at 4:07 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Sun, May 26, 2013 at 10:36 PM, Peter Brooks peter.h.m.bro...@gmail.com 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

Solving the problem of mutual recursion

2013-05-26 Thread Peter Brooks
I'm not sure if this'll interest anybody, but I expect that I'm going to get some mutual recursion in my simulation, so I needed to see how python handled it. Unfortunately, it falls over once it detects a certain level of recursion. This is reasonable as, otherwise, the stack eventually

Re: Solving the problem of mutual recursion

2013-05-26 Thread Jussi Piitulainen
Peter Brooks writes: I'm not sure if this'll interest anybody, but I expect that I'm going to get some mutual recursion in my simulation, so I needed to ... returned, then this solution won't help you. Often, though, you're not interested in what's returned and would just like the routine to

Re: Solving the problem of mutual recursion

2013-05-26 Thread Roy Smith
In article qota9nhu6ag@ruuvi.it.helsinki.fi, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: A light-weighter way is to have each task end by assigning the next task and returning, instead of calling the next task directly. When a task returns, a driver loop will call the assigned

Re: Solving the problem of mutual recursion

2013-05-26 Thread Peter Brooks
On May 26, 5:09 pm, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: A light-weighter way is to have each task end by assigning the next task and returning, instead of calling the next task directly. When a task returns, a driver loop will call the assigned task, which again does a bounded

RE: Solving the problem of mutual recursion

2013-05-26 Thread Carlos Nepomuceno
Date: Sun, 26 May 2013 10:21:05 -0700 Subject: Re: Solving the problem of mutual recursion From: peter.h.m.bro...@gmail.com To: python-list@python.org On May 26, 5:09 pm, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: A light-weighter way

Re: Solving the problem of mutual recursion

2013-05-26 Thread Peter Brooks
On 26 May, 20:09, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote: Date: Sun, 26 May 2013 10:21:05 -0700 Subject: Re: Solving the problem of mutual recursion From: peter.h.m.bro...@gmail.com To: python-l...@python.org On May 26, 5

RE: Solving the problem of mutual recursion

2013-05-26 Thread Carlos Nepomuceno
Date: Sun, 26 May 2013 11:13:12 -0700 Subject: Re: Solving the problem of mutual recursion From: peter.h.m.bro...@gmail.com To: python-list@python.org [...] How can you get 140% of CPU? IS that a typo?? No, on a multi-core machine it's normal

Re: Solving the problem of mutual recursion

2013-05-26 Thread Peter Brooks
On 26 May, 20:22, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote: Date: Sun, 26 May 2013 11:13:12 -0700 Subject: Re: Solving the problem of mutual recursion From: peter.h.m.bro...@gmail.com To: python-l...@python.org [...] How can you get

Re: Solving the problem of mutual recursion

2013-05-26 Thread Ian Kelly
On Sun, May 26, 2013 at 12:13 PM, Peter Brooks peter.h.m.bro...@gmail.com wrote: No, on a multi-core machine it's normal. The machine shows python running multiple threads - and the number of threads change as the program runs. Perhaps the OS/X implementation of python does allow concurrency

Re: Solving the problem of mutual recursion

2013-05-26 Thread Chris Angelico
On Mon, May 27, 2013 at 5:35 AM, Ian Kelly ian.g.ke...@gmail.com wrote: I'm pretty sure that CPython uses the GIL regardless of platform. And yes you can have multiple OS-level threads, but because of the GIL only one will actually be running at a time. Other possibilities include: 6) It's

Re: Solving the problem of mutual recursion

2013-05-26 Thread Peter Brooks
On May 27, 12:16 am, Chris Angelico ros...@gmail.com wrote: On Mon, May 27, 2013 at 5:35 AM, Ian Kelly ian.g.ke...@gmail.com wrote: I'm pretty sure that CPython uses the GIL regardless of platform.  And yes you can have multiple OS-level threads, but because of the GIL only one will