[Python-checkins] python/dist/src/Lib asynchat.py,1.21,1.22

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Fri Feb 6 22:19:12 EST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24421
Modified Files:
	asynchat.py 
Log Message:
Use collection.deque() instead of a list for a FIFO queue.
Index: asynchat.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/asynchat.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** asynchat.py	10 Mar 2003 15:16:54 -0000	1.21
--- asynchat.py	7 Feb 2004 03:19:10 -0000	1.22
***************
*** 49,52 ****
--- 49,53 ----
 import socket
 import asyncore
+ from collections import deque
 
 class async_chat (asyncore.dispatcher):
***************
*** 251,257 ****
 def __init__ (self, list=None):
 if not list:
! self.list = []
 else:
! self.list = list
 
 def __len__ (self):
--- 252,258 ----
 def __init__ (self, list=None):
 if not list:
! self.list = deque()
 else:
! self.list = deque(list)
 
 def __len__ (self):
***************
*** 262,273 ****
 
 def first (self):
! return self.list[0]
 
 def push (self, data):
! self.list.append (data)
 
 def pop (self):
 if self.list:
! return (1, self.list.pop(0))
 else:
 return (0, None)
--- 263,278 ----
 
 def first (self):
! it = iter(self.list)
! try:
! return it.next()
! except StopIteration:
! raise IndexError
 
 def push (self, data):
! self.list.append(data)
 
 def pop (self):
 if self.list:
! return (1, self.list.popleft())
 else:
 return (0, None)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /