[Python-3000] Futures in Python 3000 (was Re: mechanism for handling asynchronous concurrency)

Andy Sy andy at neotitans.com
Wed Apr 19 07:41:40 CEST 2006


Josiah Carlson wrote:
> Andy Sy <andy at neotitans.com> wrote:
>> The Io language has what (on paper) seems to be a very
>> neat, Pythonic mechanism for doing asynchronous concurrency.
>>
>>
>> The mechanism is called futures and is described at:
>>
>> http://iolanguage.com/darcs/Io/_docs/guide.html#TOC17133
>>
>>
>> Perhaps Python 3000 can incorporate some similar ideas
>> in its syntax or standard library?
> 
> This has been the case since Python 2.2 (if I remember correctly), see
> generators.  Python 2.5 adds a mechanism to pass information back into
> generators (gen.send()).
> 
>  - Josiah

I am quite aware of what generators are, thank you.

Io's 'Futures' syntax seems to be a far simpler and more general way to
express general asynchronous concepts (like waiting for I/O to complete -
try dealing with that using generators...) whereas generator syntax is
more suited to the specific case of lazy iteration.  You will still need
to do an implementation of coroutines in terms of generators and not
have a natural syntax for it.

I don't know about you, but with the addition of send() to deal with
the problem outlined in PEP 342, generators are starting to look more
and more like a Rube Goldberg contraption.  Could anything be more
Pythonic than Io's:

f := url @fetch  // f is a future that will eventually hold the
                 // URL's contents, but you don't block on the fetch.



A futures abtraction and corresponding Python syntax might offer a
clean start.  It sounds like futures are very closely related to what
Stackless is trying to achieve but does so in a far more lucid way.

I found some additional info regarding Futures below:

http://www.ps.uni-sb.de/alice/manual/futures.html
http://kasparov.skife.org/blog-live/src/futures.writeback
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Future.html

Apparently, this abstraction is not limited to Io alone.



More information about the Python-3000 mailing list