Index: Tools/pybench/pybench.py =================================================================== --- Tools/pybench/pybench.py (revision 82254) +++ Tools/pybench/pybench.py (working copy) @@ -10,8 +10,8 @@ # module Setup.py. # -from __future__ import print_function + # pybench Copyright __copyright__ = """\ Copyright (c), 1997-2006, Marc-Andre Lemburg (mal@lemburg.com) @@ -37,13 +37,10 @@ import sys, time, operator, platform from CommandLine import * +# XXX: Pretend we don't have _pickle +sys.modules['_pickle'] = None +import pickle -try: - import cPickle - pickle = cPickle -except ImportError: - import pickle - # Version number; version history: see README file ! __version__ = '2.1' @@ -267,7 +264,7 @@ calibrate = self.calibrate timer = self.get_timer() - calibration_loops = range(CALIBRATION_LOOPS) + calibration_loops = list(range(CALIBRATION_LOOPS)) # Time the calibration loop overhead prep_times = [] @@ -474,7 +471,7 @@ if self.verbose: print('Searching for tests ...') print('--------------------------------------') - for testclass in setupmod.__dict__.values(): + for testclass in list(setupmod.__dict__.values()): if not hasattr(testclass, 'is_a_test'): continue name = testclass.__name__ Index: Tools/pybench/Strings.py =================================================================== --- Tools/pybench/Strings.py (revision 82254) +++ Tools/pybench/Strings.py (working copy) @@ -16,8 +16,8 @@ def test(self): # Make sure the strings are *not* interned - s = ''.join(map(str,range(100))) - t = ''.join(map(str,range(1,101))) + s = ''.join(map(str,list(range(100)))) + t = ''.join(map(str,list(range(1,101)))) for i in range(self.rounds): t + s @@ -82,8 +82,8 @@ def calibrate(self): - s = ''.join(map(str,range(100))) - t = ''.join(map(str,range(1,101))) + s = ''.join(map(str,list(range(100)))) + t = ''.join(map(str,list(range(1,101)))) for i in range(self.rounds): pass @@ -98,8 +98,8 @@ def test(self): # Make sure the strings are *not* interned - s = ''.join(map(str,range(10))) - t = ''.join(map(str,range(10))) + "abc" + s = ''.join(map(str,list(range(10)))) + t = ''.join(map(str,list(range(10)))) + "abc" for i in range(self.rounds): t < s @@ -164,8 +164,8 @@ def calibrate(self): - s = ''.join(map(str,range(10))) - t = ''.join(map(str,range(10))) + "abc" + s = ''.join(map(str,list(range(10)))) + t = ''.join(map(str,list(range(10)))) + "abc" for i in range(self.rounds): pass @@ -180,7 +180,7 @@ def test(self): # Make sure the strings *are* interned - s = intern(''.join(map(str,range(10)))) + s = sys.intern(''.join(map(str,list(range(10))))) t = s for i in range(self.rounds): @@ -246,7 +246,7 @@ def calibrate(self): - s = intern(''.join(map(str,range(10)))) + s = sys.intern(''.join(map(str,list(range(10))))) t = s for i in range(self.rounds): @@ -336,7 +336,7 @@ def test(self): - s = ''.join(map(str,range(100))) + s = ''.join(map(str,list(range(100)))) for i in range(self.rounds): @@ -382,7 +382,7 @@ def calibrate(self): - s = ''.join(map(str,range(100))) + s = ''.join(map(str,list(range(100)))) for i in range(self.rounds): pass @@ -399,10 +399,10 @@ def test(self): - s = ''.join(map(chr,range(20))) - t = ''.join(map(chr,range(50))) - u = ''.join(map(chr,range(100))) - v = ''.join(map(chr,range(256))) + s = ''.join(map(chr,list(range(20)))) + t = ''.join(map(chr,list(range(50)))) + u = ''.join(map(chr,list(range(100)))) + v = ''.join(map(chr,list(range(256)))) for i in range(self.rounds): @@ -456,10 +456,10 @@ def calibrate(self): - s = ''.join(map(chr,range(20))) - t = ''.join(map(chr,range(50))) - u = ''.join(map(chr,range(100))) - v = ''.join(map(chr,range(256))) + s = ''.join(map(chr,list(range(20)))) + t = ''.join(map(chr,list(range(50)))) + u = ''.join(map(chr,list(range(100)))) + v = ''.join(map(chr,list(range(256)))) for i in range(self.rounds): pass Index: Tools/pybench/clockres.py =================================================================== --- Tools/pybench/clockres.py (revision 82254) +++ Tools/pybench/clockres.py (working copy) @@ -16,7 +16,7 @@ wallclock = time.time start = wallclock() stop = wallclock() + TEST_TIME - spin_loops = range(1000) + spin_loops = list(range(1000)) while 1: now = wallclock() if now >= stop: @@ -33,10 +33,10 @@ if __name__ == '__main__': print('Clock resolution of various timer implementations:') - print('time.clock: %10.3fus' % (clockres(time.clock) * 1e6)) - print('time.time: %10.3fus' % (clockres(time.time) * 1e6)) + print(('time.clock: %10.3fus' % (clockres(time.clock) * 1e6))) + print(('time.time: %10.3fus' % (clockres(time.time) * 1e6))) try: import systimes - print('systimes.processtime: %10.3fus' % (clockres(systimes.processtime) * 1e6)) + print(('systimes.processtime: %10.3fus' % (clockres(systimes.processtime) * 1e6))) except ImportError: pass Index: Tools/pybench/Constructs.py =================================================================== --- Tools/pybench/Constructs.py (revision 82254) +++ Tools/pybench/Constructs.py (working copy) @@ -475,9 +475,9 @@ def test(self): - l1 = range(1000) - l2 = range(10) - l3 = range(5) + l1 = list(range(1000)) + l2 = list(range(10)) + l3 = list(range(5)) for i in range(self.rounds): for i in l1: for j in l2: @@ -486,9 +486,9 @@ def calibrate(self): - l1 = range(1000) - l2 = range(10) - l3 = range(5) + l1 = list(range(1000)) + l2 = list(range(10)) + l3 = list(range(5)) for i in range(self.rounds): pass @@ -500,7 +500,7 @@ def test(self): - l1 = range(100) + l1 = list(range(100)) for i in range(self.rounds): for i in l1: pass @@ -559,6 +559,6 @@ def calibrate(self): - l1 = range(1000) + l1 = list(range(1000)) for i in range(self.rounds): pass Index: Tools/pybench/With.py =================================================================== --- Tools/pybench/With.py (revision 82254) +++ Tools/pybench/With.py (working copy) @@ -1,4 +1,4 @@ -from __future__ import with_statement + from pybench import Test class WithFinally(Test): Index: Tools/pybench/Tuples.py =================================================================== --- Tools/pybench/Tuples.py (revision 82254) +++ Tools/pybench/Tuples.py (working copy) @@ -8,7 +8,7 @@ def test(self): - r = range(25) + r = list(range(25)) t = tuple(range(100)) for i in range(self.rounds): @@ -257,7 +257,7 @@ def calibrate(self): - r = range(25) + r = list(range(25)) t = tuple(range(100)) for i in range(self.rounds): Index: Tools/pybench/systimes.py =================================================================== --- Tools/pybench/systimes.py (revision 82254) +++ Tools/pybench/systimes.py (working copy) @@ -32,8 +32,8 @@ """ -from __future__ import print_function + import time, sys # Index: Tools/pybench/CommandLine.py =================================================================== --- Tools/pybench/CommandLine.py (revision 82254) +++ Tools/pybench/CommandLine.py (working copy) @@ -11,8 +11,8 @@ """ -from __future__ import print_function + __copyright__ = """\ Copyright (c), 1997-2006, Marc-Andre Lemburg (mal@lemburg.com) Copyright (c), 2000-2006, eGenix.com Software GmbH (info@egenix.com) @@ -125,8 +125,8 @@ continue m = integerRange.match(entry) if m: - start,end = map(int,m.groups()) - l[len(l):] = range(start,end+1) + start,end = list(map(int,m.groups())) + l[len(l):] = list(range(start,end+1)) return l def abspath(path, Index: Tools/pybench/Unicode.py =================================================================== --- Tools/pybench/Unicode.py (revision 82254) +++ Tools/pybench/Unicode.py (working copy) @@ -1,5 +1,5 @@ try: - unicode + str except NameError: raise ImportError @@ -14,8 +14,8 @@ def test(self): # Make sure the strings are *not* interned - s = unicode(u''.join(map(str,range(100)))) - t = unicode(u''.join(map(str,range(1,101)))) + s = str(''.join(map(str,list(range(100))))) + t = str(''.join(map(str,list(range(1,101))))) for i in range(self.rounds): t + s @@ -80,8 +80,8 @@ def calibrate(self): - s = unicode(u''.join(map(str,range(100)))) - t = unicode(u''.join(map(str,range(1,101)))) + s = str(''.join(map(str,list(range(100))))) + t = str(''.join(map(str,list(range(1,101))))) for i in range(self.rounds): pass @@ -96,8 +96,8 @@ def test(self): # Make sure the strings are *not* interned - s = unicode(u''.join(map(str,range(10)))) - t = unicode(u''.join(map(str,range(10))) + "abc") + s = str(''.join(map(str,list(range(10))))) + t = str(''.join(map(str,list(range(10)))) + "abc") for i in range(self.rounds): t < s @@ -162,8 +162,8 @@ def calibrate(self): - s = unicode(u''.join(map(str,range(10)))) - t = unicode(u''.join(map(str,range(10))) + "abc") + s = str(''.join(map(str,list(range(10))))) + t = str(''.join(map(str,list(range(10)))) + "abc") for i in range(self.rounds): pass @@ -178,65 +178,65 @@ def test(self): for i in range(self.rounds): - s = u'om' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = 'om' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' - s = s + u'xax' - s = s + u'xbx' - s = s + u'xcx' - s = s + u'xdx' - s = s + u'xex' + s = s + 'xax' + s = s + 'xbx' + s = s + 'xcx' + s = s + 'xdx' + s = s + 'xex' def calibrate(self): @@ -252,7 +252,7 @@ def test(self): - s = unicode(u''.join(map(str,range(100)))) + s = str(''.join(map(str,list(range(100))))) for i in range(self.rounds): @@ -298,7 +298,7 @@ def calibrate(self): - s = unicode(u''.join(map(str,range(100)))) + s = str(''.join(map(str,list(range(100))))) for i in range(self.rounds): pass @@ -313,10 +313,10 @@ def test(self): - s = u''.join(map(unichr,range(20))) - t = u''.join(map(unichr,range(100))) - u = u''.join(map(unichr,range(500))) - v = u''.join(map(unichr,range(1000))) + s = ''.join(map(chr,list(range(20)))) + t = ''.join(map(chr,list(range(100)))) + u = ''.join(map(chr,list(range(500)))) + v = ''.join(map(chr,list(range(1000)))) for i in range(self.rounds): @@ -370,10 +370,10 @@ def calibrate(self): - s = u''.join(map(unichr,range(20))) - t = u''.join(map(unichr,range(100))) - u = u''.join(map(unichr,range(500))) - v = u''.join(map(unichr,range(1000))) + s = ''.join(map(chr,list(range(20)))) + t = ''.join(map(chr,list(range(100)))) + u = ''.join(map(chr,list(range(500)))) + v = ''.join(map(chr,list(range(1000)))) for i in range(self.rounds): pass @@ -386,7 +386,7 @@ def test(self): - data = (u'abc', u'123', u' ', u'\u1234\u2345\u3456', u'\uFFFF'*10) + data = ('abc', '123', ' ', '\u1234\u2345\u3456', '\uFFFF'*10) len_data = len(data) for i in range(self.rounds): @@ -444,7 +444,7 @@ def calibrate(self): - data = (u'abc', u'123', u' ', u'\u1234\u2345\u3456', u'\uFFFF'*10) + data = ('abc', '123', ' ', '\u1234\u2345\u3456', '\uFFFF'*10) len_data = len(data) for i in range(self.rounds): @@ -463,7 +463,7 @@ def test(self): - data = (u'a', u'1', u' ', u'\u1234', u'\uFFFF') + data = ('a', '1', ' ', '\u1234', '\uFFFF') len_data = len(data) digit = unicodedata.digit numeric = unicodedata.numeric @@ -525,7 +525,7 @@ def calibrate(self): - data = (u'a', u'1', u' ', u'\u1234', u'\uFFFF') + data = ('a', '1', ' ', '\u1234', '\uFFFF') len_data = len(data) digit = unicodedata.digit numeric = unicodedata.numeric