Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 1 | import dis |
Antoine Pitrou | b7fbcd3 | 2010-01-16 18:37:38 +0000 | [diff] [blame] | 2 | import re |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 3 | import sys |
Guido van Rossum | 34d1928 | 2007-08-09 01:03:29 +0000 | [diff] [blame] | 4 | from io import StringIO |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 5 | import unittest |
| 6 | |
| 7 | def disassemble(func): |
| 8 | f = StringIO() |
| 9 | tmp = sys.stdout |
| 10 | sys.stdout = f |
Antoine Pitrou | 17b880a | 2011-03-11 17:27:02 +0100 | [diff] [blame^] | 11 | try: |
| 12 | dis.dis(func) |
| 13 | finally: |
| 14 | sys.stdout = tmp |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 15 | result = f.getvalue() |
| 16 | f.close() |
| 17 | return result |
| 18 | |
| 19 | def dis_single(line): |
| 20 | return disassemble(compile(line, '', 'single')) |
| 21 | |
| 22 | class TestTranforms(unittest.TestCase): |
| 23 | |
| 24 | def test_unot(self): |
Jeffrey Yasskin | 9de7ec7 | 2009-02-25 02:25:04 +0000 | [diff] [blame] | 25 | # UNARY_NOT POP_JUMP_IF_FALSE --> POP_JUMP_IF_TRUE' |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 26 | def unot(x): |
| 27 | if not x == 2: |
| 28 | del x |
| 29 | asm = disassemble(unot) |
Jeffrey Yasskin | 9de7ec7 | 2009-02-25 02:25:04 +0000 | [diff] [blame] | 30 | for elem in ('UNARY_NOT', 'POP_JUMP_IF_FALSE'): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 31 | self.assertNotIn(elem, asm) |
Jeffrey Yasskin | 9de7ec7 | 2009-02-25 02:25:04 +0000 | [diff] [blame] | 32 | for elem in ('POP_JUMP_IF_TRUE',): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 33 | self.assertIn(elem, asm) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 34 | |
| 35 | def test_elim_inversion_of_is_or_in(self): |
| 36 | for line, elem in ( |
| 37 | ('not a is b', '(is not)',), |
| 38 | ('not a in b', '(not in)',), |
| 39 | ('not a is not b', '(is)',), |
| 40 | ('not a not in b', '(in)',), |
| 41 | ): |
| 42 | asm = dis_single(line) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 43 | self.assertIn(elem, asm) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 44 | |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 45 | def test_global_as_constant(self): |
| 46 | # LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 47 | def f(x): |
Tim Peters | 66cb018 | 2004-08-26 05:23:19 +0000 | [diff] [blame] | 48 | None |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 49 | None |
Tim Peters | 66cb018 | 2004-08-26 05:23:19 +0000 | [diff] [blame] | 50 | return x |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 51 | def g(x): |
| 52 | True |
| 53 | return x |
| 54 | def h(x): |
| 55 | False |
| 56 | return x |
| 57 | for func, name in ((f, 'None'), (g, 'True'), (h, 'False')): |
| 58 | asm = disassemble(func) |
| 59 | for elem in ('LOAD_GLOBAL',): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 60 | self.assertNotIn(elem, asm) |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 61 | for elem in ('LOAD_CONST', '('+name+')'): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 62 | self.assertIn(elem, asm) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 63 | def f(): |
| 64 | 'Adding a docstring made this test fail in Py2.5.0' |
| 65 | return None |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 66 | self.assertIn('LOAD_CONST', disassemble(f)) |
| 67 | self.assertNotIn('LOAD_GLOBAL', disassemble(f)) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 68 | |
| 69 | def test_while_one(self): |
Jeffrey Yasskin | 9de7ec7 | 2009-02-25 02:25:04 +0000 | [diff] [blame] | 70 | # Skip over: LOAD_CONST trueconst POP_JUMP_IF_FALSE xx |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 71 | def f(): |
Tim Peters | 66cb018 | 2004-08-26 05:23:19 +0000 | [diff] [blame] | 72 | while 1: |
| 73 | pass |
| 74 | return list |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 75 | asm = disassemble(f) |
Jeffrey Yasskin | 9de7ec7 | 2009-02-25 02:25:04 +0000 | [diff] [blame] | 76 | for elem in ('LOAD_CONST', 'POP_JUMP_IF_FALSE'): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 77 | self.assertNotIn(elem, asm) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 78 | for elem in ('JUMP_ABSOLUTE',): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 79 | self.assertIn(elem, asm) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 80 | |
| 81 | def test_pack_unpack(self): |
| 82 | for line, elem in ( |
Raymond Hettinger | 2c31a05 | 2004-09-22 18:44:21 +0000 | [diff] [blame] | 83 | ('a, = a,', 'LOAD_CONST',), |
| 84 | ('a, b = a, b', 'ROT_TWO',), |
| 85 | ('a, b, c = a, b, c', 'ROT_THREE',), |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 86 | ): |
| 87 | asm = dis_single(line) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 88 | self.assertIn(elem, asm) |
| 89 | self.assertNotIn('BUILD_TUPLE', asm) |
| 90 | self.assertNotIn('UNPACK_TUPLE', asm) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 91 | |
Raymond Hettinger | 2c31a05 | 2004-09-22 18:44:21 +0000 | [diff] [blame] | 92 | def test_folding_of_tuples_of_constants(self): |
| 93 | for line, elem in ( |
Raymond Hettinger | 5dec096 | 2004-11-02 04:20:10 +0000 | [diff] [blame] | 94 | ('a = 1,2,3', '((1, 2, 3))'), |
| 95 | ('("a","b","c")', "(('a', 'b', 'c'))"), |
| 96 | ('a,b,c = 1,2,3', '((1, 2, 3))'), |
| 97 | ('(None, 1, None)', '((None, 1, None))'), |
| 98 | ('((1, 2), 3, 4)', '(((1, 2), 3, 4))'), |
Raymond Hettinger | 2c31a05 | 2004-09-22 18:44:21 +0000 | [diff] [blame] | 99 | ): |
| 100 | asm = dis_single(line) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 101 | self.assertIn(elem, asm) |
| 102 | self.assertNotIn('BUILD_TUPLE', asm) |
Raymond Hettinger | 2c31a05 | 2004-09-22 18:44:21 +0000 | [diff] [blame] | 103 | |
Antoine Pitrou | 17b880a | 2011-03-11 17:27:02 +0100 | [diff] [blame^] | 104 | # Long tuples should be folded too. |
| 105 | asm = dis_single(repr(tuple(range(10000)))) |
| 106 | # One LOAD_CONST for the tuple, one for the None return value |
| 107 | self.assertEqual(asm.count('LOAD_CONST'), 2) |
| 108 | self.assertNotIn('BUILD_TUPLE', asm) |
| 109 | |
Raymond Hettinger | 23109ef | 2004-10-26 08:59:14 +0000 | [diff] [blame] | 110 | # Bug 1053819: Tuple of constants misidentified when presented with: |
| 111 | # . . . opcode_with_arg 100 unary_opcode BUILD_TUPLE 1 . . . |
| 112 | # The following would segfault upon compilation |
| 113 | def crater(): |
| 114 | (~[ |
| 115 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 116 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 117 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 118 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 119 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 120 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 121 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 122 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 123 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 124 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
| 125 | ],) |
| 126 | |
Antoine Pitrou | b7fbcd3 | 2010-01-16 18:37:38 +0000 | [diff] [blame] | 127 | def test_folding_of_lists_of_constants(self): |
| 128 | for line, elem in ( |
| 129 | # in/not in constants with BUILD_LIST should be folded to a tuple: |
| 130 | ('a in [1,2,3]', '(1, 2, 3)'), |
| 131 | ('a not in ["a","b","c"]', "(('a', 'b', 'c'))"), |
| 132 | ('a in [None, 1, None]', '((None, 1, None))'), |
| 133 | ('a not in [(1, 2), 3, 4]', '(((1, 2), 3, 4))'), |
| 134 | ): |
| 135 | asm = dis_single(line) |
| 136 | self.assertIn(elem, asm) |
| 137 | self.assertNotIn('BUILD_LIST', asm) |
| 138 | |
| 139 | def test_folding_of_sets_of_constants(self): |
| 140 | for line, elem in ( |
| 141 | # in/not in constants with BUILD_SET should be folded to a frozenset: |
| 142 | ('a in {1,2,3}', frozenset({1, 2, 3})), |
| 143 | ('a not in {"a","b","c"}', frozenset({'a', 'c', 'b'})), |
| 144 | ('a in {None, 1, None}', frozenset({1, None})), |
| 145 | ('a not in {(1, 2), 3, 4}', frozenset({(1, 2), 3, 4})), |
| 146 | ('a in {1, 2, 3, 3, 2, 1}', frozenset({1, 2, 3})), |
| 147 | ): |
| 148 | asm = dis_single(line) |
| 149 | self.assertNotIn('BUILD_SET', asm) |
| 150 | |
| 151 | # Verify that the frozenset 'elem' is in the disassembly |
| 152 | # The ordering of the elements in repr( frozenset ) isn't |
| 153 | # guaranteed, so we jump through some hoops to ensure that we have |
| 154 | # the frozenset we expect: |
| 155 | self.assertIn('frozenset', asm) |
| 156 | # Extract the frozenset literal from the disassembly: |
| 157 | m = re.match(r'.*(frozenset\({.*}\)).*', asm, re.DOTALL) |
| 158 | self.assertTrue(m) |
| 159 | self.assertEqual(eval(m.group(1)), elem) |
| 160 | |
| 161 | # Ensure that the resulting code actually works: |
| 162 | def f(a): |
| 163 | return a in {1, 2, 3} |
| 164 | |
| 165 | def g(a): |
| 166 | return a not in {1, 2, 3} |
| 167 | |
| 168 | self.assertTrue(f(3)) |
| 169 | self.assertTrue(not f(4)) |
| 170 | |
| 171 | self.assertTrue(not g(3)) |
| 172 | self.assertTrue(g(4)) |
| 173 | |
| 174 | |
Raymond Hettinger | c34f867 | 2005-01-02 06:17:33 +0000 | [diff] [blame] | 175 | def test_folding_of_binops_on_constants(self): |
| 176 | for line, elem in ( |
| 177 | ('a = 2+3+4', '(9)'), # chained fold |
| 178 | ('"@"*4', "('@@@@')"), # check string ops |
| 179 | ('a="abc" + "def"', "('abcdef')"), # check string ops |
| 180 | ('a = 3**4', '(81)'), # binary power |
| 181 | ('a = 3*4', '(12)'), # binary multiply |
Raymond Hettinger | c34f867 | 2005-01-02 06:17:33 +0000 | [diff] [blame] | 182 | ('a = 13//4', '(3)'), # binary floor divide |
| 183 | ('a = 14%4', '(2)'), # binary modulo |
| 184 | ('a = 2+3', '(5)'), # binary add |
| 185 | ('a = 13-4', '(9)'), # binary subtract |
| 186 | ('a = (12,13)[1]', '(13)'), # binary subscr |
| 187 | ('a = 13 << 2', '(52)'), # binary lshift |
| 188 | ('a = 13 >> 2', '(3)'), # binary rshift |
| 189 | ('a = 13 & 7', '(5)'), # binary and |
| 190 | ('a = 13 ^ 7', '(10)'), # binary xor |
| 191 | ('a = 13 | 7', '(15)'), # binary or |
| 192 | ): |
| 193 | asm = dis_single(line) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 194 | self.assertIn(elem, asm, asm) |
| 195 | self.assertNotIn('BINARY_', asm) |
Raymond Hettinger | c34f867 | 2005-01-02 06:17:33 +0000 | [diff] [blame] | 196 | |
| 197 | # Verify that unfoldables are skipped |
| 198 | asm = dis_single('a=2+"b"') |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 199 | self.assertIn('(2)', asm) |
| 200 | self.assertIn("('b')", asm) |
Raymond Hettinger | c34f867 | 2005-01-02 06:17:33 +0000 | [diff] [blame] | 201 | |
Raymond Hettinger | 9feb267 | 2005-01-26 12:50:05 +0000 | [diff] [blame] | 202 | # Verify that large sequences do not result from folding |
| 203 | asm = dis_single('a="x"*1000') |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 204 | self.assertIn('(1000)', asm) |
Raymond Hettinger | 9feb267 | 2005-01-26 12:50:05 +0000 | [diff] [blame] | 205 | |
Raymond Hettinger | afd842f | 2005-02-20 12:46:54 +0000 | [diff] [blame] | 206 | def test_folding_of_unaryops_on_constants(self): |
| 207 | for line, elem in ( |
Raymond Hettinger | afd842f | 2005-02-20 12:46:54 +0000 | [diff] [blame] | 208 | ('-0.5', '(-0.5)'), # unary negative |
| 209 | ('~-2', '(1)'), # unary invert |
Raymond Hettinger | af7adad | 2009-10-22 11:22:50 +0000 | [diff] [blame] | 210 | ('+1', '(1)'), # unary positive |
Raymond Hettinger | afd842f | 2005-02-20 12:46:54 +0000 | [diff] [blame] | 211 | ): |
| 212 | asm = dis_single(line) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 213 | self.assertIn(elem, asm, asm) |
| 214 | self.assertNotIn('UNARY_', asm) |
Raymond Hettinger | afd842f | 2005-02-20 12:46:54 +0000 | [diff] [blame] | 215 | |
| 216 | # Verify that unfoldables are skipped |
| 217 | for line, elem in ( |
| 218 | ('-"abc"', "('abc')"), # unary negative |
| 219 | ('~"abc"', "('abc')"), # unary invert |
| 220 | ): |
| 221 | asm = dis_single(line) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 222 | self.assertIn(elem, asm, asm) |
| 223 | self.assertIn('UNARY_', asm) |
Raymond Hettinger | afd842f | 2005-02-20 12:46:54 +0000 | [diff] [blame] | 224 | |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 225 | def test_elim_extra_return(self): |
| 226 | # RETURN LOAD_CONST None RETURN --> RETURN |
| 227 | def f(x): |
| 228 | return x |
| 229 | asm = disassemble(f) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 230 | self.assertNotIn('LOAD_CONST', asm) |
| 231 | self.assertNotIn('(None)', asm) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 232 | self.assertEqual(asm.split().count('RETURN_VALUE'), 1) |
| 233 | |
Thomas Wouters | 89f507f | 2006-12-13 04:49:30 +0000 | [diff] [blame] | 234 | def test_elim_jump_to_return(self): |
| 235 | # JUMP_FORWARD to RETURN --> RETURN |
| 236 | def f(cond, true_value, false_value): |
| 237 | return true_value if cond else false_value |
| 238 | asm = disassemble(f) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 239 | self.assertNotIn('JUMP_FORWARD', asm) |
| 240 | self.assertNotIn('JUMP_ABSOLUTE', asm) |
Thomas Wouters | 89f507f | 2006-12-13 04:49:30 +0000 | [diff] [blame] | 241 | self.assertEqual(asm.split().count('RETURN_VALUE'), 2) |
| 242 | |
| 243 | def test_elim_jump_after_return1(self): |
| 244 | # Eliminate dead code: jumps immediately after returns can't be reached |
| 245 | def f(cond1, cond2): |
| 246 | if cond1: return 1 |
| 247 | if cond2: return 2 |
| 248 | while 1: |
| 249 | return 3 |
| 250 | while 1: |
| 251 | if cond1: return 4 |
| 252 | return 5 |
| 253 | return 6 |
| 254 | asm = disassemble(f) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 255 | self.assertNotIn('JUMP_FORWARD', asm) |
| 256 | self.assertNotIn('JUMP_ABSOLUTE', asm) |
Thomas Wouters | 89f507f | 2006-12-13 04:49:30 +0000 | [diff] [blame] | 257 | self.assertEqual(asm.split().count('RETURN_VALUE'), 6) |
| 258 | |
| 259 | def test_elim_jump_after_return2(self): |
| 260 | # Eliminate dead code: jumps immediately after returns can't be reached |
| 261 | def f(cond1, cond2): |
| 262 | while 1: |
| 263 | if cond1: return 4 |
| 264 | asm = disassemble(f) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 265 | self.assertNotIn('JUMP_FORWARD', asm) |
Thomas Wouters | 89f507f | 2006-12-13 04:49:30 +0000 | [diff] [blame] | 266 | # There should be one jump for the while loop. |
| 267 | self.assertEqual(asm.split().count('JUMP_ABSOLUTE'), 1) |
| 268 | self.assertEqual(asm.split().count('RETURN_VALUE'), 2) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 269 | |
Guido van Rossum | 0240b92 | 2007-02-26 21:23:50 +0000 | [diff] [blame] | 270 | def test_make_function_doesnt_bail(self): |
| 271 | def f(): |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 272 | def g()->1+1: |
Guido van Rossum | 0240b92 | 2007-02-26 21:23:50 +0000 | [diff] [blame] | 273 | pass |
| 274 | return g |
| 275 | asm = disassemble(f) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 276 | self.assertNotIn('BINARY_ADD', asm) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 277 | |
Antoine Pitrou | 17b880a | 2011-03-11 17:27:02 +0100 | [diff] [blame^] | 278 | def test_constant_folding(self): |
| 279 | # Issue #11244: aggressive constant folding. |
| 280 | exprs = [ |
| 281 | "3 * -5", |
| 282 | "-3 * 5", |
| 283 | "2 * (3 * 4)", |
| 284 | "(2 * 3) * 4", |
| 285 | "(-1, 2, 3)", |
| 286 | "(1, -2, 3)", |
| 287 | "(1, 2, -3)", |
| 288 | "(1, 2, -3) * 6", |
| 289 | "lambda x: x in {(3 * -5) + (-1 - 6), (1, -2, 3) * 2, None}", |
| 290 | ] |
| 291 | for e in exprs: |
| 292 | asm = dis_single(e) |
| 293 | self.assertNotIn('UNARY_', asm, e) |
| 294 | self.assertNotIn('BINARY_', asm, e) |
| 295 | self.assertNotIn('BUILD_', asm, e) |
| 296 | |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 297 | |
| 298 | def test_main(verbose=None): |
| 299 | import sys |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 300 | from test import support |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 301 | test_classes = (TestTranforms,) |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 302 | support.run_unittest(*test_classes) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 303 | |
| 304 | # verify reference counting |
| 305 | if verbose and hasattr(sys, "gettotalrefcount"): |
| 306 | import gc |
| 307 | counts = [None] * 5 |
Guido van Rossum | 805365e | 2007-05-07 22:24:25 +0000 | [diff] [blame] | 308 | for i in range(len(counts)): |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 309 | support.run_unittest(*test_classes) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 310 | gc.collect() |
| 311 | counts[i] = sys.gettotalrefcount() |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 312 | print(counts) |
Raymond Hettinger | fd2d1f7 | 2004-08-23 23:37:48 +0000 | [diff] [blame] | 313 | |
| 314 | if __name__ == "__main__": |
| 315 | test_main(verbose=True) |