[Python-ideas] Fwd: Concurrent safety?

Mike Meyer mwm at mired.org
Wed Nov 2 20:47:01 CET 2011


On Wed, Nov 2, 2011 at 12:31 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 2 November 2011 18:10, Mike Meyer <mwm at mired.org> wrote:
>> You don't have to do anything. Iterators need to lock themselves to be
>> safe in concurrent use, so this will work fine, with the temporary
>> iterator doing whatever locking is needed.
> So all iterators automatically lock themselves? Sounds like
> potentially quite an overhead.

No, all iterators are written to be thread safe. This is pretty much a
requirement if you want to use them in a threaded environment. Some
iterators may be able to do this without locking. I suspect most
won't.

This makes me wonder about something. Is there a high-performance
threading world that 1) doesn't assume that threading is the norm and
thus doesn't worry about single-threaded performance (this is the
impression I get about Java, but I may well be wrong) and 2) doesn't
require knowing at either build (C/C++) or launch (haskell) time that
it's going to be threaded? I haven't found such.

    <mike



More information about the Python-ideas mailing list