[Python-checkins] r58896 - in python/trunk: Misc/NEWS Python/ceval.c

raymond.hettinger python-checkins at python.org
Wed Nov 7 03:45:46 CET 2007


Author: raymond.hettinger
Date: Wed Nov  7 03:45:46 2007
New Revision: 58896

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Python/ceval.c
Log:
Add build option for faster loop execution.

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Nov  7 03:45:46 2007
@@ -1042,6 +1042,11 @@
 Build
 -----
 
+- Add a FAST_LOOPS build option that speeds-up looping by trading away
+  periodic threadstate and signal checking in tight loops.  By default,
+  this option is turned-off.  It should only be enabled in debugged,
+  performance critical applications.
+
 - Patch #786737: Allow building in a tree of symlinks pointing to
   a readonly source.
 

Modified: python/trunk/Python/ceval.c
==============================================================================
--- python/trunk/Python/ceval.c	(original)
+++ python/trunk/Python/ceval.c	Wed Nov  7 03:45:46 2007
@@ -2159,7 +2159,18 @@
 		PREDICTED_WITH_ARG(JUMP_ABSOLUTE);
 		case JUMP_ABSOLUTE:
 			JUMPTO(oparg);
+#if FAST_LOOPS
+			/* Enabling this path speeds-up all while and for-loops by bypassing
+                           the per-loop checks for signals.  By default, this should be turned-off
+                           because it prevents detection of a control-break in tight loops like
+                           "while 1: pass".  Compile with this option turned-on when you need
+                           the speed-up and do not need break checking inside tight loops (ones
+                           that contain only instructions ending with goto fast_next_opcode). 
+                        */
+			goto fast_next_opcode;
+#else
 			continue;
+#endif
 
 		case GET_ITER:
 			/* before: [obj]; after [getiter(obj)] */


More information about the Python-checkins mailing list