Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63408

Re: Trying to wrap my head around futures and coroutines

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '"this': 0.03; 'linear': 0.09; 'mentions': 0.09; 'seen,': 0.09; 'sentence': 0.09; 'python': 0.11; 'clear.': 0.16; 'concurrent': 0.16; 'coroutines': 0.16; 'event-driven': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'hypothetical': 0.16; 'paradigms': 0.16; 'readable': 0.16; 'sockets': 0.16; 'sender:addr:gmail.com': 0.17; 'module': 0.19; 'trying': 0.19; 'written': 0.21; 'code,': 0.22; 'programming': 0.22; 'skip': 0.24; 'versions': 0.24; "i've": 0.25; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'related': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'easier': 0.31; 'running': 0.33; 'implemented': 0.33; 'objects': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'algorithms': 0.60; 'introduced': 0.61; 'first': 0.61; 'myself': 0.63; 'today': 0.64; 'more': 0.64; 'tasks.': 0.68; 'fact,': 0.69; 'overall': 0.69; 'manner': 0.72; 'picture.': 0.84; 'responses': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=Q7vyeOxyZgagF/dNwSM3NrOJzrVW40i3Vd/na8N3+fs=; b=ANnBiFqMSW5A69hTNrwsDVWIySuSj82aZRAH60ypU6XRef4ehrxIltPF07rTjT1hBy 2vj11FaO4P+LEJgMu9GNu6cCu/olBV2jNQoEljm+TbLLlcQ7Ak4Ou9xnjAnqkl16wtw7 g16Bfl5AajfJtvsJWP1NZInlQIEeGy8vEhywWRCTpYJGULnFoIbwqD6SIzCrONxhvuXj JbOGK8GGqj+JBSnBQaVydp5NPQ3kZcx2pOaLsLVVMnb4942s2dFYMYspApCIDNPM7VZ9 /PjyXYOKzyBS/HV8WotVxIuPm/NvlJJ3F/Y7uv0b5UlbhzFjOS/9LDb6kjjUOq70KyJj sfxA==
MIME-Version 1.0
X-Received by 10.50.114.168 with SMTP id jh8mr22925230igb.6.1389064556891; Mon, 06 Jan 2014 19:15:56 -0800 (PST)
Sender skip.montanaro@gmail.com
In-Reply-To <20140107024521.GA75679@cskk.homeip.net>
References <20140107022958.GA59457@cskk.homeip.net> <20140107024521.GA75679@cskk.homeip.net>
Date Mon, 6 Jan 2014 21:15:56 -0600
X-Google-Sender-Auth jM8QAjan267d1g86KYfOK76jspk
Subject Re: Trying to wrap my head around futures and coroutines
From Skip Montanaro <skip@pobox.com>
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5117.1389064565.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389064565 news.xs4all.nl 2870 [2001:888:2000:d::a6]:60719
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63408

Show key headers only | View raw


>From the couple responses I've seen, I must have not made myself
clear. Let's skip specific hypothetical tasks. Using coroutines,
futures, or other programming paradigms that have been introduced in
recent versions of Python 3.x, can traditionally event-driven code be
written in a more linear manner so that the overall algorithms
implemented in the code are easier to follow? My code is not
multi-threaded, so using threads and locking is not really part of the
picture. In fact, I'm thinking about this now precisely because the
first sentence of the asyncio documentation mentions single-threaded
concurrent code: "This module provides infrastructure for writing
single-threaded concurrent code using coroutines, multiplexing I/O
access over sockets and other resources, running network clients and
servers, and other related primitives."

I'm trying to understand if it's possible to use coroutines or objects
like asyncio.Future to write more readable code, that today would be
implemented using callbacks, GTK signals, etc.

S

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Trying to wrap my head around futures and coroutines Skip Montanaro <skip@pobox.com> - 2014-01-06 21:15 -0600

csiph-web