Re: [Python-Dev] Autoloading? (Making Queue.Queue easier to use)
John Camera writes:
It sounds like he feels Queue should just be part of threading but queues can be used in other contexts besides threading. So having separate modules is a good thing.
Michael Chermside Perhaps I am wrong here, but the Queue.Queue class is designed specifically for synchronization, and I have always been under the impression that it was probably NOT the best tool for normal queues that have nothing to do with threading. Why incur the overhead of synchronization locks when you don't intend to use them. I would advise against using Queue.Queue in any context besides threading.
I haven't used the Queue class before as I normally use a list for a queue. I just assumed a Queue was just a queue that was perhaps optimized for performance. I guess I would have expected the Queue class as defined in the standard library to have a different name if it wasn't just a queue. Well I should have known better than to make assumption on this list. :) I now see where Greg is coming from but I'm still not comfortable having it in the threading module. To me threads and queues are two different beasts. John M. Camara
john.m.camara@comcast.net wrote:
I now see where Greg is coming from but I'm still not comfortable having it in the threading module. To me threads and queues are two different beasts.
All right then, how about putting it in a module called threadutils or something like that, which is clearly related to threading, but is open for the addition of future thread-related features that might arise. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg.ewing@canterbury.ac.nz +--------------------------------------+
Greg> All right then, how about putting it in a module called Greg> threadutils or something like that, which is clearly related to Greg> threading, but is open for the addition of future thread-related Greg> features that might arise. Then Lock, RLock, Semaphore, etc belong there instead of in threading don't they? We have two things here, the basic thread object and the stuff it does (run, start, etc) and the synchronization primitives. Thread objects come in two levels of abstraction: thread.thread and threading.Thread. The synchronization primitives come in three levels of abstraction: thread.lock, threading.{Lock,Semaphore,...} and Queue.Queue. Each level of abstraction builds on the level below. In the typical case I think we want to encourage programmers to use the highest levels of abstraction available and leave the lower level stuff to the real pros. That means most programmers using threads should use threading.Thread and Queue.Queue. Partitioning the various classes to different modules might look like this: Module Thread Classes Sync Primitives ------ -------------- --------------- _thread thread lock threadutils Lock, RLock, Semaphore thread Thread Queue Programmers would clearly be discouraged from using the _thread module (currently thread). The typical case would be to import the thread module (currently threading) and use its Thread and Queue objects. For specialized use the threadutils programmer can import the threadutils module to get at the synchronization primitives it contains. Skip
On 10/13/05, skip@pobox.com <skip@pobox.com> wrote:
Greg> All right then, how about putting it in a module called Greg> threadutils or something like that, which is clearly related to Greg> threading, but is open for the addition of future thread-related Greg> features that might arise.
Then Lock, RLock, Semaphore, etc belong there instead of in threading don't they?
No. Locks and semaphores are the lowest-level threading primitives. They go in the basic module. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (4)
-
Greg Ewing -
Guido van Rossum -
john.m.camara@comcast.net -
skip@pobox.com