Mercurial > cpython-lru_cache-weakref
annotate Modules/_decimal/tests/randfloat.py @ 84007:dbfbdf2b5c19 3.3
Fix #17967: For ftp urls CWD to target instead of hopping to each directory
towards target. This fixes a bug where target is accessible, but parent
directories are restricted.
| author | Senthil Kumaran <senthil@uthcode.com> |
|---|---|
| date | Sat, 01 Jun 2013 08:27:06 -0700 |
| parents | 7355550d5357 |
| children |
| rev | line source |
|---|---|
|
75850
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
1 # Copyright (c) 2010 Python Software Foundation. All Rights Reserved. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
2 # Adapted from Python's Lib/test/test_strtod.py (by Mark Dickinson) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
3 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
4 # More test cases for deccheck.py. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
5 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
6 import random |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
7 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
8 TEST_SIZE = 2 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
9 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
10 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
11 def test_short_halfway_cases(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
12 # exact halfway cases with a small number of significant digits |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
13 for k in 0, 5, 10, 15, 20: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
14 # upper = smallest integer >= 2**54/5**k |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
15 upper = -(-2**54//5**k) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
16 # lower = smallest odd number >= 2**53/5**k |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
17 lower = -(-2**53//5**k) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
18 if lower % 2 == 0: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
19 lower += 1 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
20 for i in range(10 * TEST_SIZE): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
21 # Select a random odd n in [2**53/5**k, |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
22 # 2**54/5**k). Then n * 10**k gives a halfway case |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
23 # with small number of significant digits. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
24 n, e = random.randrange(lower, upper, 2), k |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
25 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
26 # Remove any additional powers of 5. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
27 while n % 5 == 0: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
28 n, e = n // 5, e + 1 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
29 assert n % 10 in (1, 3, 7, 9) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
30 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
31 # Try numbers of the form n * 2**p2 * 10**e, p2 >= 0, |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
32 # until n * 2**p2 has more than 20 significant digits. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
33 digits, exponent = n, e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
34 while digits < 10**20: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
35 s = '{}e{}'.format(digits, exponent) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
36 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
37 # Same again, but with extra trailing zeros. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
38 s = '{}e{}'.format(digits * 10**40, exponent - 40) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
39 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
40 digits *= 2 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
41 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
42 # Try numbers of the form n * 5**p2 * 10**(e - p5), p5 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
43 # >= 0, with n * 5**p5 < 10**20. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
44 digits, exponent = n, e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
45 while digits < 10**20: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
46 s = '{}e{}'.format(digits, exponent) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
47 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
48 # Same again, but with extra trailing zeros. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
49 s = '{}e{}'.format(digits * 10**40, exponent - 40) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
50 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
51 digits *= 5 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
52 exponent -= 1 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
53 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
54 def test_halfway_cases(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
55 # test halfway cases for the round-half-to-even rule |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
56 for i in range(1000): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
57 for j in range(TEST_SIZE): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
58 # bit pattern for a random finite positive (or +0.0) float |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
59 bits = random.randrange(2047*2**52) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
60 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
61 # convert bit pattern to a number of the form m * 2**e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
62 e, m = divmod(bits, 2**52) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
63 if e: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
64 m, e = m + 2**52, e - 1 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
65 e -= 1074 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
66 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
67 # add 0.5 ulps |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
68 m, e = 2*m + 1, e - 1 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
69 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
70 # convert to a decimal string |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
71 if e >= 0: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
72 digits = m << e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
73 exponent = 0 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
74 else: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
75 # m * 2**e = (m * 5**-e) * 10**e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
76 digits = m * 5**-e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
77 exponent = e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
78 s = '{}e{}'.format(digits, exponent) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
79 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
80 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
81 def test_boundaries(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
82 # boundaries expressed as triples (n, e, u), where |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
83 # n*10**e is an approximation to the boundary value and |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
84 # u*10**e is 1ulp |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
85 boundaries = [ |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
86 (10000000000000000000, -19, 1110), # a power of 2 boundary (1.0) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
87 (17976931348623159077, 289, 1995), # overflow boundary (2.**1024) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
88 (22250738585072013831, -327, 4941), # normal/subnormal (2.**-1022) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
89 (0, -327, 4941), # zero |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
90 ] |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
91 for n, e, u in boundaries: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
92 for j in range(1000): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
93 for i in range(TEST_SIZE): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
94 digits = n + random.randrange(-3*u, 3*u) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
95 exponent = e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
96 s = '{}e{}'.format(digits, exponent) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
97 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
98 n *= 10 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
99 u *= 10 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
100 e -= 1 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
101 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
102 def test_underflow_boundary(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
103 # test values close to 2**-1075, the underflow boundary; similar |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
104 # to boundary_tests, except that the random error doesn't scale |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
105 # with n |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
106 for exponent in range(-400, -320): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
107 base = 10**-exponent // 2**1075 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
108 for j in range(TEST_SIZE): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
109 digits = base + random.randrange(-1000, 1000) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
110 s = '{}e{}'.format(digits, exponent) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
111 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
112 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
113 def test_bigcomp(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
114 for ndigs in 5, 10, 14, 15, 16, 17, 18, 19, 20, 40, 41, 50: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
115 dig10 = 10**ndigs |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
116 for i in range(100 * TEST_SIZE): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
117 digits = random.randrange(dig10) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
118 exponent = random.randrange(-400, 400) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
119 s = '{}e{}'.format(digits, exponent) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
120 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
121 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
122 def test_parsing(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
123 # make '0' more likely to be chosen than other digits |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
124 digits = '000000123456789' |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
125 signs = ('+', '-', '') |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
126 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
127 # put together random short valid strings |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
128 # \d*[.\d*]?e |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
129 for i in range(1000): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
130 for j in range(TEST_SIZE): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
131 s = random.choice(signs) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
132 intpart_len = random.randrange(5) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
133 s += ''.join(random.choice(digits) for _ in range(intpart_len)) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
134 if random.choice([True, False]): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
135 s += '.' |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
136 fracpart_len = random.randrange(5) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
137 s += ''.join(random.choice(digits) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
138 for _ in range(fracpart_len)) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
139 else: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
140 fracpart_len = 0 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
141 if random.choice([True, False]): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
142 s += random.choice(['e', 'E']) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
143 s += random.choice(signs) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
144 exponent_len = random.randrange(1, 4) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
145 s += ''.join(random.choice(digits) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
146 for _ in range(exponent_len)) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
147 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
148 if intpart_len + fracpart_len: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
149 yield s |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
150 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
151 test_particular = [ |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
152 # squares |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
153 '1.00000000100000000025', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
154 '1.0000000000000000000000000100000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
155 '00025', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
156 '1.0000000000000000000000000000000000000000000010000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
157 '0000000000000000000000000000000000000000025', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
158 '1.0000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
159 '000001000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
160 '000000000025', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
161 '0.99999999900000000025', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
162 '0.9999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
163 '999000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
164 '000025', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
165 '0.9999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
166 '999999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
167 '999999999999999999999999999999999999999990000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
168 '000000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
169 '000000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
170 '0000000000000000000000000000025', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
171 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
172 '1.0000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
173 '000000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
174 '100000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
175 '000000000000000000000000000000000000000000000000001', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
176 '1.0000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
177 '000000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
178 '500000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
179 '000000000000000000000000000000000000000000000000005', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
180 '1.0000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
181 '000000000100000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
182 '000000000000000000250000000000000002000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
183 '000000000000000000000000000000000000000000010000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
184 '000000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
185 '0000000000000000001', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
186 '1.0000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
187 '000000000100000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
188 '000000000000000000249999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
189 '999999999999979999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
190 '999999999999999999999900000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
191 '000000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
192 '00000000000000000000000001', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
193 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
194 '0.9999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
195 '999999999900000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
196 '000000000000000000249999999999999998000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
197 '000000000000000000000000000000000000000000010000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
198 '000000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
199 '0000000000000000001', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
200 '0.9999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
201 '999999999900000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
202 '000000000000000000250000001999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
203 '999999999999999999999999999999999990000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
204 '000000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
205 '1', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
206 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
207 # tough cases for ln etc. |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
208 '1.000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
209 '00000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
210 '00100000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
211 '00000000000000000000000000000000000000000000000000' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
212 '0001', |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
213 '0.999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
214 '99999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
215 '99899999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
216 '99999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
217 '99999999999999999999999999999999999999999999999999' #... |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
218 '9999' |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
219 ] |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
220 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
221 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
222 TESTCASES = [ |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
223 [x for x in test_short_halfway_cases()], |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
224 [x for x in test_halfway_cases()], |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
225 [x for x in test_boundaries()], |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
226 [x for x in test_underflow_boundary()], |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
227 [x for x in test_bigcomp()], |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
228 [x for x in test_parsing()], |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
229 test_particular |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
230 ] |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
231 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
232 def un_randfloat(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
233 for i in range(1000): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
234 l = random.choice(TESTCASES[:6]) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
235 yield random.choice(l) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
236 for v in test_particular: |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
237 yield v |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
238 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
239 def bin_randfloat(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
240 for i in range(1000): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
241 l1 = random.choice(TESTCASES) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
242 l2 = random.choice(TESTCASES) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
243 yield random.choice(l1), random.choice(l2) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
244 |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
245 def tern_randfloat(): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
246 for i in range(1000): |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
247 l1 = random.choice(TESTCASES) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
248 l2 = random.choice(TESTCASES) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
249 l3 = random.choice(TESTCASES) |
|
7355550d5357
Issue #7652: Integrate the decimal floating point libmpdec library to speed
Stefan Krah <skrah@bytereef.org>
parents:
diff
changeset
|
250 yield random.choice(l1), random.choice(l2), random.choice(l3) |
