Mercurial > ~astiob > upreckon > hgweb
comparison problem.py @ 75:007f7eb6fb2b
The test context stack is now a deque.
Deques have a faster pop() than lists do.
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Thu, 06 Jan 2011 23:53:31 +0200 |
parents | aea4fc87698a |
children | 0e5ae28e0b2b |
comparison
equal
deleted
inserted
replaced
74:aea4fc87698a | 75:007f7eb6fb2b |
---|---|
11 __main__.import_error(sys.exc_info()[1]) | 11 __main__.import_error(sys.exc_info()[1]) |
12 else: | 12 else: |
13 from __main__ import clock, options | 13 from __main__ import clock, options |
14 | 14 |
15 import os, re, sys | 15 import os, re, sys |
16 | |
17 try: | |
18 from collections import deque | |
19 except ImportError: | |
20 deque = list | |
16 | 21 |
17 try: | 22 try: |
18 import signal | 23 import signal |
19 except ImportError: | 24 except ImportError: |
20 signalnames = () | 25 signalnames = () |
101 raise NotImplementedError | 106 raise NotImplementedError |
102 | 107 |
103 def test(prob): | 108 def test(prob): |
104 case = None | 109 case = None |
105 try: | 110 try: |
106 contexts = [TestGroup()] | 111 contexts = deque((TestGroup(),)) |
107 for case in prob.testcases: | 112 for case in prob.testcases: |
108 if case is test_context_end: | 113 if case is test_context_end: |
109 for case, correct, granted in contexts.pop().end(): | 114 for case, correct, granted in contexts.pop().end(): |
110 contexts[-1].case_start(case) | 115 contexts[-1].case_start(case) |
111 if correct: | 116 if correct: |