[Python-checkins] python/nondist/sandbox/parrotbench b6.py, NONE,
1.1 out6, NONE, 1.1 Makefile, 1.1, 1.2 README.txt, 1.1,
1.2 b.py, 1.4, 1.5 b5.py, 1.3, 1.4 out5, 1.4, 1.5
gvanrossum at users.sourceforge.net
gvanrossum at users.sourceforge.net
Wed Dec 31 02:55:00 EST 2003
Update of /cvsroot/python/python/nondist/sandbox/parrotbench
In directory sc8-pr-cvs1:/tmp/cvs-serv737
Modified Files:
Makefile README.txt b.py b5.py out5
Added Files:
b6.py out6
Log Message:
Add some forgotten builtins. Add a mild stress test for long for loops.
--- NEW FILE: b6.py ---
from b5 import check
def main():
L = [1]*1000000
L[-1] = 42
n = 0
for i in L:
n += i
check(i, 42)
check(n, 1000041)
n = 0
for i in xrange(1000000):
n += i
check(i, 999999)
check(n, 999999*1000000//2)
d = dict.fromkeys(xrange(1000000))
n = 0
for i in d:
n += i
check(n, 999999*1000000//2)
if __name__ == '__main__':
main()
--- NEW FILE: out6 -ひく-ひく-ひく
42 =わ=わ 42
1000041 =わ=わ 1000041
999999 =わ=わ 999999
499999500000L == 499999500000L
499999500000L == 499999500000L
Index: Makefile
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/parrotbench/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Makefile 31 Dec 2003 06:27:49 -0000 1.1
--- Makefile 31 Dec 2003 07:54:58 -0000 1.2
***************
*** 15,19 ****
times:
! for i in 0 1 2 3 4 5; do \
echo b$$i.py; \
time python b$$i.py >@out$$i; \
--- 15,19 ----
times:
! for i in 0 1 2 3 4 5 6; do \
echo b$$i.py; \
time python b$$i.py >@out$$i; \
***************
*** 22,26 ****
cmps:
! for i in 0 1 2 3 4 5; do \
echo b$$i.py; \
python b$$i.py >@out$$i; \
--- 22,26 ----
cmps:
! for i in 0 1 2 3 4 5 6; do \
echo b$$i.py; \
python b$$i.py >@out$$i; \
***************
*** 29,33 ****
diffs:
! for i in 0 1 2 3 4 5; do \
echo b$$i.py; \
python b$$i.py >@out$$i; \
--- 29,33 ----
diffs:
! for i in 0 1 2 3 4 5 6; do \
echo b$$i.py; \
python b$$i.py >@out$$i; \
***************
*** 35,39 ****
done
! all: out out0 out1 out2 out3 out4 out5
out: b.py b?.py
--- 35,39 ----
done
! all: out out0 out1 out2 out3 out4 out5 out6
out: b.py b?.py
***************
*** 57,58 ****
--- 57,61 ----
out5: b5.py
python b5.py >out5
+
+ out6: b6.py
+ python b6.py >out6
Index: README.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/parrotbench/README.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** README.txt 31 Dec 2003 07:31:19 -0000 1.1
--- README.txt 31 Dec 2003 07:54:58 -0000 1.2
***************
*** 43,46 ****
--- 43,48 ----
mutable classes.
+ b6.py -- Check speed of iterating over several common iterators.
+
Note that per agreement I'm not allowed to use any built-in extension
modules, not even __builtin__ or sys. This means there's no access to
Index: b.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/parrotbench/b.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** b.py 31 Dec 2003 05:39:55 -0000 1.4
--- b.py 31 Dec 2003 07:54:58 -0000 1.5
***************
*** 5,6 ****
--- 5,7 ----
import b4
import b5; b5.main()
+ import b6; b6.main()
Index: b5.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/parrotbench/b5.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** b5.py 31 Dec 2003 06:43:47 -0000 1.3
--- b5.py 31 Dec 2003 07:54:58 -0000 1.4
***************
*** 80,83 ****
--- 80,113 ----
check(long("42", 16), 66)
+ check(isinstance(42, int), True)
+ check(isinstance(42, long), False)
+ check(isinstance(42L, int), False)
+ check(isinstance(42L, long), True)
+ check(isinstance(12345678910, int), False)
+ check(isinstance(12345678910, long), True)
+ check(isinstance(3.14, int), False)
+ check(isinstance(3.14, float), True)
+ check(isinstance(int, type), True)
+ check(isinstance(int, object), True)
+ check(isinstance(type, object), True)
+
+ check(issubclass(int, object), True)
+ check(issubclass(int, int), True)
+ check(issubclass(bool, int), True)
+ check(issubclass(int, str), False)
+ check(issubclass(str, int), False)
+ check(issubclass(type, object), True)
+
+ it = iter("abcdef")
+ for i, c in enumerate(it):
+ check(c, chr(ord('a') + i))
+ if i == 2:
+ break
+ check(it.next(), "d")
+ check(it.next(), "e")
+ check(it.next(), "f")
+ exception(StopIteration, it.next)
+ exception(StopIteration, it.next)
+
check(map(None, range(5)), range(5))
check(map(None, range(5), range(5)),
***************
*** 86,89 ****
--- 116,124 ----
check(map(len, ("", "a", "ab", "abc")), range(4))
+ check(max(1, 5), 5)
+ check(max([3, 1, 2]), 3)
+ check(max("Bac"), "c")
+ check(max(u"aBc"), u"c")
+
check(min(1, 5), 1)
check(min([3, 1, 2]), 1)
***************
*** 127,130 ****
--- 162,169 ----
for x in 42, 42L, 3.5, 4.5j, 4j+3, "abc", range(3), (1, 2, 'c'), {}:
check(repr(x), `x`)
+
+ check(round(3.14), 3.0)
+ check(round(3.14, 1), 3.1)
+ check(round(31.4, -1), 30.0)
check(str(42), "42")
Index: out5
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/parrotbench/out5,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** out5 31 Dec 2003 06:43:47 -0000 1.4
--- out5 31 Dec 2003 07:54:58 -0000 1.5
***************
*** 44,51 ****
--- 44,80 ----
34L == 34
66L == 66
+ True == True
+ False == False
+ False == False
+ True == True
+ False == False
+ True == True
+ False == False
+ True == True
+ True == True
+ True == True
+ True == True
+ True == True
+ True == True
+ True == True
+ False == False
+ False == False
+ True == True
+ 'a' == 'a'
+ 'b' == 'b'
+ 'c' == 'c'
+ 'd' == 'd'
+ 'e' == 'e'
+ 'f' == 'f'
+ next() raised StopIteration
+ next() raised StopIteration
[0, 1, 2, 3, 4] == [0, 1, 2, 3, 4]
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)] == [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
[1, 2, 3, 4, 5] == [1, 2, 3, 4, 5]
[0, 1, 2, 3] == [0, 1, 2, 3]
+ 5 == 5
+ 3 == 3
+ 'c' == 'c'
+ u'c' == u'c'
1 == 1
1 == 1
***************
*** 85,88 ****
--- 114,120 ----
"(1, 2, 'c')" == "(1, 2, 'c')"
'{}' == '{}'
+ 3.0 == 3.0
+ 3.1000000000000001 =わ=わ 3.1000000000000001
+ 30.0 == 30.0
'42' == '42'
'42' == '42'
More information about the Python-checkins
mailing list