changeset 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
files problem.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/problem.py	Thu Jan 06 20:06:42 2011 +0200
+++ b/problem.py	Thu Jan 06 23:53:31 2011 +0200
@@ -15,6 +15,11 @@
 import os, re, sys
 
 try:
+	from collections import deque
+except ImportError:
+	deque = list
+
+try:
 	import signal
 except ImportError:
 	signalnames = ()
@@ -103,7 +108,7 @@
 	def test(prob):
 		case = None
 		try:
-			contexts = [TestGroup()]
+			contexts = deque((TestGroup(),))
 			for case in prob.testcases:
 				if case is test_context_end:
 					for case, correct, granted in contexts.pop().end():