[Twisted-Python] Re: [Twisted-commits] r13446 - After a lengthy discussion, revert to previous threaded behavior wrt registering as the IO thread

James Y Knight foom at fuhm.net
Mon Apr 4 20:28:55 EDT 2005

On Apr 4, 2005, at 7:03 PM, Glyph Lefkowitz wrote:
> The rationale for having this mess in the first place is that importing
> the 'thread' module slows Python down by about 30%, even if you don't
> actually run any threads.  Originally Twisted could run without
> importing 'thread' at all even on a threaded platform - if we are going
> to make the default resolver be threaded, then it's not clear how we
> would restore that feature without leaving this mess intact and making
> sure that installing the chosen resolver is done very early in the 
> process's lifetime.

(summarized conversation, many lines cut):
[19:56] <foom> exarkun: how do you demonstrate that python slows down 
if you import thread?
[19:56] <foom> python -c 'import thread; import test.pystone; 
[19:56] <foom> doesn't show any slowdown vs not import thread'ing
[19:57] * exarkun tries some stuff
[20:13] <foom> it *does* slow down if you actually call 
thread.start_new_thread(lambda:0, ())
[20:14] <foom> on a new system, ever so slightly
[20:14] <foom> on an old system, a lot
[20:15] <foom> 31250 vs 17668 pystones on my RH73 system running py2.2
[20:15] <foom> 52631 vs 49504 pystones on my FC3 system py2.3
[20:16] <foom> 57471 vs 56179 pystones (on FC3 py2.4)
[20:18] <exarkun> a previous point release of 2.2 or 2.3 might have 
moved the PyEval_InitThreads() from threadmodule's init to 
[20:21] <exarkun> hmm, no
[20:21] <exarkun> PyEval_InitThreads has been in start_new_thread for 8 
years :)
[20:22] <exarkun> hrm
[20:22] <exarkun> I suppose that doesn't tell us anything about whether 
another call to it was recently remove from the init function though
[20:27] <foom> exarkun: Instead, I'll run pystone on python1.5.2 and 
have the same behavior
[20:27] <foom> exarkun: and conclude that it's always been like that

1) We do not need to worry about importing the thread module slowing 
anything down.
2) We do not need to worry about using the thread module slowing 
anything down, on modern systems.

Therefore, the rationale for the mess is invalid, and the mess can go 


More information about the Twisted-Python mailing list