thread. question

Carl Banks pavlovevidence at gmail.com
Fri Feb 13 05:36:05 EST 2009


On Feb 9, 7:34 am, Tim Wintle <tim.win... at teamrubber.com> wrote:
> Thanks for both replies,
>
> On Mon, 2009-02-09 at 15:59 +0100, Christian Heimes wrote:
> > You shouldn't use the thread module directly. It's not meant to be used
> > by a user. Please stick to the threading module. You won't notice a
> > slowdown, trust me :)
>
> I'm aware that thread is being renamed to _thread in python 3.0, but is
> it being depricated or anything like that?
>
> This is for an app that has been running for quite a long time and it's
> now time for fairly heavy optimisations as load is increasing (Believe
> me, I wouldn't have been looking at the C otherwise) - so I'll see if I
> do notice any effect with threading.

The threading module is likely to be slightly slower when spawning new
threads, because the Thread class has a bit of overhead that allows
you to do things like thread.join().

Simple locking will be same speed whether you use the threading or
thread module, because threading.Lock and thread.acquire return the
same type of object.  This is an implementation detail, though.


Carl Banks



More information about the Python-list mailing list