Commits

Christian Heimes committed 96d5a15

The empty tuple is usually a singleton with a much higher refcnt than 1

  • Participants
  • Parent commits d4434f0
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Modules/itertoolsmodule.c

 			}
 			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). */