]> granicus.if.org Git - python/commitdiff
Add build option for faster loop execution.
authorRaymond Hettinger <python@rcn.com>
Wed, 7 Nov 2007 02:45:46 +0000 (02:45 +0000)
committerRaymond Hettinger <python@rcn.com>
Wed, 7 Nov 2007 02:45:46 +0000 (02:45 +0000)
Misc/NEWS
Python/ceval.c

index 997a49a1469b439cbce52d86fe016277fb60cf65..b67420b1d000ec5193925651c87d53abf9cf0c63 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1042,6 +1042,11 @@ Tools/Demos
 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.
 
index 245b08cf23f27684b25179caaa0d8b135e2069e7..f86c4fc51608a240f3b779d66ba9f5c90b45c662 100644 (file)
@@ -2159,7 +2159,18 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                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)] */