Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'implements': 0.05; 'operations.': 0.05; 'threads,': 0.07; 'python': 0.07; '(rather': 0.09; 'description,': 0.09; 'finished,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'relies': 0.09; 'binary': 0.14; 'subject:python': 0.15; 'bound,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'modules?': 0.16; 'share?': 0.16; 'subject:threads': 0.16; 'threading': 0.16; 'zipfile': 0.16; 'code.': 0.18; 'programming': 0.20; 'code': 0.22; 'header:In- Reply-To:1': 0.22; 'gil': 0.23; 'runs': 0.24; 'received:84': 0.25; 'classes': 0.26; 'google': 0.27; 'supports': 0.29; 'acceptable': 0.29; 'fine.': 0.29; 'gather': 0.29; 'opposed': 0.29; 'stefan': 0.29; 'model': 0.31; 'i/o': 0.31; 'lock': 0.31; 'modules,': 0.31; 'objects.': 0.31; 'threads': 0.31; 'does': 0.31; 'to:addr:python- list': 0.32; 'posts': 0.33; 'operations': 0.33; 'sometimes': 0.33; 'uses': 0.34; 'using': 0.34; 'header:X-Complaints-To:1': 0.34; 'that,': 0.35; 'question': 0.35; 'header:User-Agent:1': 0.35; 'usually': 0.36; 'doing': 0.36; 'some': 0.37; 'thread': 0.38; 'received:org': 0.38; 'not,': 0.39; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'header:Received:5': 0.40; 'full': 0.62; 'articles': 0.67; 'subject:About': 0.77 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: About threads in python Date: Thu, 21 Apr 2011 16:09:20 +0200 References: <47d21fd4-22d3-4ee0-bdc2-a3643af4fc9e@t16g2000vbi.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: dslb-084-056-009-176.pools.arcor-ip.net User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 In-Reply-To: <47d21fd4-22d3-4ee0-bdc2-a3643af4fc9e@t16g2000vbi.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303394975 news.xs4all.nl 65870 [::ffff:82.94.164.166]:48736 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3799 dutche, 21.04.2011 15:19: > Here's the thing...I had to make a program with threads and after > finished, I found some posts and articles in Google about Python and > threads, raising the question about if it really implements thread > programming or not, because of GIL and the way Python needs to lock > some objects. > > I have now in my program something about 8 threads and each of them > runs different code based on some directives, these codes relies > sometimes in C api, using classes like zipfile and tarfile, and others > relies only in python code. What do you mean by "relies sometimes on C api"? Do you mean that it uses binary modules, as opposed to Python modules? > My question is about the efficiency of threads in python, does anybody > has something to share? From your (rather unspecific) description, I gather that you are doing mostly I/O operations. Threading is an acceptable programming model for that, and Python supports it just fine. The GIL is usually released for I/O operations by the runtime, so if your program is I/O bound, you will get full threading concurrency. Stefan