[Python-checkins] r61102 - python/trunk/Modules/itertoolsmodule.c

christian.heimes python-checkins at python.org
Thu Feb 28 12:18:50 CET 2008


Author: christian.heimes
Date: Thu Feb 28 12:18:49 2008
New Revision: 61102

Modified:
   python/trunk/Modules/itertoolsmodule.c
Log:
The empty tuple is usually a singleton with a much higher refcnt than 1

Modified: python/trunk/Modules/itertoolsmodule.c
==============================================================================
--- python/trunk/Modules/itertoolsmodule.c	(original)
+++ python/trunk/Modules/itertoolsmodule.c	Thu Feb 28 12:18:49 2008
@@ -2111,8 +2111,11 @@
 			}
 			Py_DECREF(old_result);
 		}
-		/* Now, we've got the only copy so we can update it in-place */
-		assert (Py_REFCNT(result) == 1);
+		/* Now, we've got the only copy so we can update it in-place 
+		 * CPython's empty tuple is a singleton and cached in 
+		 * PyTuple's freelist. 
+		 */
+		assert(r == 0 || Py_REFCNT(result) == 1);
 
                 /* Scan indices right-to-left until finding one that is not
                    at its maximum (i + n - r). */


More information about the Python-checkins mailing list