[Python-checkins] python/dist/src/Lib tempfile.py,1.51,1.52
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 21 Nov 2002 08:00:02 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv26380/python/Lib
Modified Files:
tempfile.py
Log Message:
_RandomNameSequence(): style guide changes, small speedup, don't
put more in the critical section than absolutely needed, acquire
the mutex before the "try".
Index: tempfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** tempfile.py 21 Nov 2002 15:48:33 -0000 1.51
--- tempfile.py 21 Nov 2002 15:59:59 -0000 1.52
***************
*** 89,95 ****
_RandomNameSequence is an iterator."""
! characters = ( "abcdefghijklmnopqrstuvwxyz"
! + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
! + "0123456789-_")
def __init__(self):
--- 89,95 ----
_RandomNameSequence is an iterator."""
! characters = ("abcdefghijklmnopqrstuvwxyz" +
! "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
! "0123456789-_")
def __init__(self):
***************
*** 97,100 ****
--- 97,101 ----
self.rng = _Random()
self.normcase = _os.path.normcase
+
def __iter__(self):
return self
***************
*** 103,116 ****
m = self.mutex
c = self.characters
! r = self.rng
try:
! m.acquire()
! letters = ''.join([r.choice(c), r.choice(c), r.choice(c),
! r.choice(c), r.choice(c), r.choice(c)])
finally:
m.release()
! return self.normcase(letters)
def _candidate_tempdir_list():
--- 104,116 ----
m = self.mutex
c = self.characters
! choose = self.rng.choice
+ m.acquire()
try:
! letters = [choose(c) for dummy in "123456"]
finally:
m.release()
! return self.normcase(''.join(letters))
def _candidate_tempdir_list():