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


Groups > comp.lang.python > #78268

Re: Dynamically swapping between two algorithms

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:two': 0.07; '"c"': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'language,': 0.12; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'spawn': 0.16; 'subject:between': 0.16; 'this)': 0.16; 'threads,': 0.16; 'prevent': 0.16; 'code.': 0.18; 'header:User-Agent:1': 0.23; 'large,': 0.24; 'first,': 0.26; 'code:': 0.26; 'header:X -Complaints-To:1': 0.27; 'function': 0.29; "d'aprano": 0.31; 'steven': 0.31; 'writes:': 0.31; 'run': 0.32; "i'd": 0.34; 'problem.': 0.35; '(2)': 0.35; 'but': 0.35; 'really': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'two': 0.37; 'level': 0.37; 'to:addr:python-list': 0.38; 'short': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'hope': 0.61; 'received:217': 0.63; 'different': 0.65; 'other.': 0.75; 'completes': 0.84; 'computation.': 0.84; 'listening,': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From dieter <dieter@handshake.de>
Subject Re: Dynamically swapping between two algorithms
Date Wed, 24 Sep 2014 09:44:26 +0200
References <54218831$0$29979$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e0b8d3.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:7CrVVaJKaqh7z6NGIexhJ4urVEg=
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.14300.1411544681.18130.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411544682 news.xs4all.nl 2897 [2001:888:2000:d::a6]:41639
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78268

Show key headers only | View raw


Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes:
> ...
> *If* Python was a different language, I would spawn two threads, one using
> SHORT and the other using LARGE, then which ever completes first, I'd just
> kill the other. Alas, this won't work because (1) the GIL

The GIL does not prevent this scenario. The two threads will not
really run in parallel but interleaved - but this should not be a big
problem.

> and (2) you
> cannot forcibly kill threads, only ask them to die and hope they listen.

You can kill threads (though you will need a "C" level function for this)
as long as they execute Python code.
And it is your code: you can make your threads be listening, from time to time
in the computation.

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


Thread

Dynamically swapping between two algorithms Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-24 00:48 +1000
  Re: Dynamically swapping between two algorithms Chris Angelico <rosuav@gmail.com> - 2014-09-24 01:24 +1000
  Re: Dynamically swapping between two algorithms emile <emile@fenx.com> - 2014-09-23 08:33 -0700
  Re: Dynamically swapping between two algorithms MRAB <python@mrabarnett.plus.com> - 2014-09-23 16:42 +0100
  Re: Dynamically swapping between two algorithms Terry Reedy <tjreedy@udel.edu> - 2014-09-23 15:21 -0400
  Re: Dynamically swapping between two algorithms C Smith <illusiontechniques@gmail.com> - 2014-09-23 13:54 -0700
  Re: Dynamically swapping between two algorithms dieter <dieter@handshake.de> - 2014-09-24 09:44 +0200
  Re: Dynamically swapping between two algorithms Cameron Simpson <cs@zip.com.au> - 2014-09-26 10:30 +1000
  Re: Dynamically swapping between two algorithms Ethan Furman <ethan@stoneleaf.us> - 2014-09-25 20:11 -0700

csiph-web