[Python-checkins]
python/dist/src/Lib Queue.py, 1.19, 1.20 mutex.py,
1.11, 1.12 pydoc.py, 1.89, 1.90 shlex.py, 1.21,
1.22 threading.py, 1.39, 1.40
rhettinger at projects.sourceforge.net
rhettinger at projects.sourceforge.net
Thu Jan 29 01:38:24 EST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1631/Lib
Modified Files:
Queue.py mutex.py pydoc.py shlex.py threading.py
Log Message:
* Move collections.deque() in from the sandbox
* Add unittests, newsitem, and whatsnew
* Apply to Queue.py mutex.py threading.py pydoc.py and shlex.py
* Docs are forthcoming
Index: Queue.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/Queue.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** Queue.py 1 Jul 2003 05:34:27 -0000 1.19
--- Queue.py 29 Jan 2004 06:37:49 -0000 1.20
***************
*** 2,5 ****
--- 2,6 ----
from time import time as _time, sleep as _sleep
+ from collections import deque
__all__ = ['Empty', 'Full', 'Queue']
***************
*** 185,189 ****
def _init(self, maxsize):
self.maxsize = maxsize
! self.queue = []
def _qsize(self):
--- 186,190 ----
def _init(self, maxsize):
self.maxsize = maxsize
! self.queue = deque()
def _qsize(self):
***************
*** 204,206 ****
# Get an item from the queue
def _get(self):
! return self.queue.pop(0)
--- 205,207 ----
# Get an item from the queue
def _get(self):
! return self.queue.popleft()
Index: mutex.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/mutex.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** mutex.py 30 Jun 2002 03:39:14 -0000 1.11
--- mutex.py 29 Jan 2004 06:37:49 -0000 1.12
***************
*** 13,21 ****
"""
class mutex:
def __init__(self):
"""Create a new mutex -- initially unlocked."""
self.locked = 0
! self.queue = []
def test(self):
--- 13,23 ----
"""
+ from collections import deque
+
class mutex:
def __init__(self):
"""Create a new mutex -- initially unlocked."""
self.locked = 0
! self.queue = deque()
def test(self):
***************
*** 45,49 ****
function with its argument."""
if self.queue:
! function, argument = self.queue.pop(0)
function(argument)
else:
--- 47,51 ----
function with its argument."""
if self.queue:
! function, argument = self.queue.popleft()
function(argument)
else:
Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.89
retrieving revision 1.90
diff -C2 -d -r1.89 -r1.90
*** pydoc.py 31 Oct 2003 13:05:21 -0000 1.89
--- pydoc.py 29 Jan 2004 06:37:49 -0000 1.90
***************
*** 56,59 ****
--- 56,60 ----
from repr import Repr
from string import expandtabs, find, join, lower, split, strip, rfind, rstrip
+ from collections import deque
# --------------------------------------------------------- common routines
***************
*** 686,690 ****
# List the mro, if non-trivial.
! mro = list(inspect.getmro(object))
if len(mro) > 2:
hr.maybe()
--- 687,691 ----
# List the mro, if non-trivial.
! mro = deque(inspect.getmro(object))
if len(mro) > 2:
hr.maybe()
***************
*** 764,768 ****
while attrs:
if mro:
! thisclass = mro.pop(0)
else:
thisclass = attrs[0][2]
--- 765,769 ----
while attrs:
if mro:
! thisclass = mro.popleft()
else:
thisclass = attrs[0][2]
***************
*** 1084,1088 ****
# List the mro, if non-trivial.
! mro = list(inspect.getmro(object))
if len(mro) > 2:
push("Method resolution order:")
--- 1085,1089 ----
# List the mro, if non-trivial.
! mro = deque(inspect.getmro(object))
if len(mro) > 2:
push("Method resolution order:")
***************
*** 1153,1157 ****
while attrs:
if mro:
! thisclass = mro.pop(0)
else:
thisclass = attrs[0][2]
--- 1154,1158 ----
while attrs:
if mro:
! thisclass = mro.popleft()
else:
thisclass = attrs[0][2]
Index: shlex.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/shlex.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** shlex.py 20 Apr 2003 01:57:02 -0000 1.21
--- shlex.py 29 Jan 2004 06:37:49 -0000 1.22
***************
*** 10,13 ****
--- 10,14 ----
import os.path
import sys
+ from collections import deque
try:
***************
*** 46,54 ****
self.escapedquotes = '"'
self.state = ' '
! self.pushback = []
self.lineno = 1
self.debug = 0
self.token = ''
! self.filestack = []
self.source = None
if self.debug:
--- 47,55 ----
self.escapedquotes = '"'
self.state = ' '
! self.pushback = deque()
self.lineno = 1
self.debug = 0
self.token = ''
! self.filestack = deque()
self.source = None
if self.debug:
***************
*** 60,64 ****
if self.debug >= 1:
print "shlex: pushing token " + `tok`
! self.pushback.insert(0, tok)
def push_source(self, newstream, newfile=None):
--- 61,65 ----
if self.debug >= 1:
print "shlex: pushing token " + `tok`
! self.pushback.appendleft(tok)
def push_source(self, newstream, newfile=None):
***************
*** 66,70 ****
if isinstance(newstream, basestring):
newstream = StringIO(newstream)
! self.filestack.insert(0, (self.infile, self.instream, self.lineno))
self.infile = newfile
self.instream = newstream
--- 67,71 ----
if isinstance(newstream, basestring):
newstream = StringIO(newstream)
! self.filestack.appendleft((self.infile, self.instream, self.lineno))
self.infile = newfile
self.instream = newstream
***************
*** 79,84 ****
"Pop the input source stack."
self.instream.close()
! (self.infile, self.instream, self.lineno) = self.filestack[0]
! self.filestack = self.filestack[1:]
if self.debug:
print 'shlex: popping to %s, line %d' \
--- 80,84 ----
"Pop the input source stack."
self.instream.close()
! (self.infile, self.instream, self.lineno) = self.filestack.popleft()
if self.debug:
print 'shlex: popping to %s, line %d' \
***************
*** 89,93 ****
"Get a token from the input stream (or from stack if it's nonempty)"
if self.pushback:
! tok = self.pushback.pop(0)
if self.debug >= 1:
print "shlex: popping token " + `tok`
--- 89,93 ----
"Get a token from the input stream (or from stack if it's nonempty)"
if self.pushback:
! tok = self.pushback.popleft()
if self.debug >= 1:
print "shlex: popping token " + `tok`
***************
*** 227,231 ****
self.token = self.token + nextchar
else:
! self.pushback.insert(0, nextchar)
if self.debug >= 2:
print "shlex: I see punctuation in word state"
--- 227,231 ----
self.token = self.token + nextchar
else:
! self.pushback.appendleft(nextchar)
if self.debug >= 2:
print "shlex: I see punctuation in word state"
Index: threading.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** threading.py 5 Nov 2003 23:02:59 -0000 1.39
--- threading.py 29 Jan 2004 06:37:49 -0000 1.40
***************
*** 11,14 ****
--- 11,15 ----
from time import time as _time, sleep as _sleep
from traceback import format_exc as _format_exc
+ from collections import deque
# Rename some stuff so "from threading import *" is safe
***************
*** 640,644 ****
self.wc = Condition(self.mon)
self.limit = limit
! self.queue = []
def put(self, item):
--- 641,645 ----
self.wc = Condition(self.mon)
self.limit = limit
! self.queue = deque()
def put(self, item):
***************
*** 658,662 ****
self._note("get(): queue empty")
self.rc.wait()
! item = self.queue.pop(0)
self._note("get(): got %s, %d left", item, len(self.queue))
self.wc.notify()
--- 659,663 ----
self._note("get(): queue empty")
self.rc.wait()
! item = self.queue.popleft()
self._note("get(): got %s, %d left", item, len(self.queue))
self.wc.notify()
More information about the Python-checkins
mailing list