Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6461
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Marc Christiansen <usenet@solar-empire.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: GIL in alternative implementations |
| Date | Sat, 28 May 2011 11:55:34 +0200 |
| Lines | 62 |
| Sender | <tolot@jupiter.solar-empire.de> |
| Message-ID | <mdt6b8-css.ln1@pluto.solar-empire.de> (permalink) |
| References | <4DE015EA.4040600@gmail.com> <mailman.2185.1306548406.9059.python-list@python.org> |
| X-Trace | news.uni-berlin.de UeL651HE/WkCuBhvtMuT/QalOCmZ6a1JJkVI46YLpFf90G15s= |
| X-Orig-Path | not-for-mail |
| User-Agent | tin/1.9.6-20101126 ("Burnside") (UNIX) (Linux/2.6.37-gentoo-r4 (x86_64)) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:6461 |
Show key headers only | View raw
Daniel Kluev <dan.kluev@gmail.com> wrote: > test.py: > > from threading import Thread > class X(object): > pass > obj = X() > obj.x = 0 > > def f(*args): > for i in range(10000): > obj.x += 1 > > threads = [] > for i in range(100): > t = Thread(target=f) > threads.append(t) > t.start() > > for t in threads: > while t.isAlive(): > t.join(1) > > print(obj.x) > >> python test.py > 1000000 >> pypy test.py > 1000000 >> jython-2.5 test.py > 19217 >> ipy test.py > 59040 > > Not that this thing is reasonable to do in real code, but cpython and > other implementations with GIL at least give you some safety margin. > Sure? ;) > for p in python2.4 python2.5 python2.6 python2.7 python3.1 python3.2; do echo $p; $p /tmp/test.py; $p /tmp/test.py; done python2.4 525369 736202 python2.5 449496 551023 python2.6 903405 937335 python2.7 885834 910144 python3.1 866557 766842 python3.2 1000000 1000000 So even CPython (at least < 3.2) isn't safe. And I wouldn't rely on 3.2 not to break. Marc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: GIL in alternative implementations Daniel Kluev <dan.kluev@gmail.com> - 2011-05-28 13:06 +1100
Re: GIL in alternative implementations Marc Christiansen <usenet@solar-empire.de> - 2011-05-28 11:55 +0200
Re: GIL in alternative implementations Wolfgang Rohdewald <wolfgang@rohdewald.de> - 2011-05-28 13:16 +0200
Re: GIL in alternative implementations John Nagle <nagle@animats.com> - 2011-05-28 09:39 -0700
Re: GIL in alternative implementations Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-28 17:05 +0000
Re: GIL in alternative implementations "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-06-07 01:03 -0300
Re: GIL in alternative implementations Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-07 07:09 +0000
Re: GIL in alternative implementations Jean-Paul Calderone <calderone.jeanpaul@gmail.com> - 2011-06-07 05:07 -0700
csiph-web