[Python-ideas] channel (synchronous queue)
Guido van Rossum
guido at python.org
Sun Feb 19 16:53:14 CET 2012
How hard would it be to add Channel to the stdlib? Perhaps even in the
threading module, which already has a bunch of different primitives
like Lock, RLock, Condition, Event, Semaphore, Barrier.
On Sun, Feb 19, 2012 at 2:05 AM, Cameron Simpson <cs at zip.com.au> wrote:
> On 19Feb2012 01:59, Sturla Molden <sturla at molden.no> wrote:
> | Den 19.02.2012 01:39, skrev Matt Joiner:
> | >
> | > Yes, channels can allow for this, but as with locks directionality and
> | > ordering matter. Typically messages will only run in a particular
> | > direction.
> | >
> | Actually, it was only a synchronous MPI_Recv that did this in MPI, a
> | synchronous
> | MPI_Send would have been even worse. Which is why MPI got the
> | asynchronous method MPI_Irecv...
> | Sounds like you just want a barrier or a condition primitive. E.g. have
> | the sender
> | call .wait() on a condition and let the receiver call .notify() the
> | condition.
> A condition is essentially a boolean (with waiting).
> A channel is a value passing mechanism.
> Sometimes you really do want a zero-storage Queue i.e. a channel.
> Saying "but you could put a value in a shared variable and just use a
> condition" removes the abstraction/metaphor. If I was thinking that way
> more than once in some code I'd write a small class to do that. And it would
> be a channel!
> Seriously, a channel is semanticly equivalent to a zero-storage Queue, which
> is a mode not provided by the current Queue implementation.
> Cameron Simpson <cs at zip.com.au> DoD#743
> No good deed shall go unpunished! - David Wood <davewood at teleport.com>
> Python-ideas mailing list
> Python-ideas at python.org
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas