Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Re: I'd like list.pop to accept an optional second argument giving a defaultvalue

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


jim at digicool

Jul 22, 1999, 7:47 AM

Post #1 of 1 (83 views)
Permalink
Re: I'd like list.pop to accept an optional second argument giving a defaultvalue

Skip Montanaro wrote:
>
> Jim> I like the list pop method because it provides a way to use lists
> Jim> as thread safe queues and stacks (since append and pop are
> Jim> protected by the global interpreter lock).
>
> The global interpreter lock is a property of the current implementation of
> Python, not of the language itself. At one point in the past Greg Stein
> created a set of patches that eliminated the lock. While it's perhaps
> convenient to use now, it may not always exist. I'm not so sure that it
> should be used as a motivator for changes to libraries in the standard
> distribution.

If the global interpreter lock goes away, then some other locking mechanism
will be used to make built-in object operations atomic. For example, in
Greg's changes, each list was protected by a list lock. The key is that
pop combines checking for an empty list and removing an element
into a single operation. As long as the operations append and pop are atomic,
then lists can be used as thread-safe stacks and queues.

The benefit of the proposal does not really depend on the global interpreter
lock. It only depends on list operations being atomic.

Jim

--
Jim Fulton mailto:jim [at] digicool Python Powered!
Technical Director (888) 344-4332 http://www.python.org
Digital Creations http://www.digicool.com http://www.zope.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission. Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.