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


Groups > comp.lang.python > #3799

Re: About threads in python

From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: About threads in python
Date 2011-04-21 16:09 +0200
References <47d21fd4-22d3-4ee0-bdc2-a3643af4fc9e@t16g2000vbi.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.703.1303394975.9059.python-list@python.org> (permalink)

Show all headers | View raw


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

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


Thread

About threads in python dutche <dutche@gmail.com> - 2011-04-21 06:19 -0700
  Re: About threads in python Stefan Behnel <stefan_ml@behnel.de> - 2011-04-21 16:09 +0200
  Re: About threads in python sturlamolden <sturlamolden@yahoo.no> - 2011-04-22 12:19 -0700
    Re: About threads in python Hans Georg Schaathun <hg@schaathun.net> - 2011-04-25 20:31 +0100

csiph-web