]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
The empty tuple is usually a singleton with a much higher refcnt than 1
authorChristian Heimes <christian@cheimes.de>
Thu, 28 Feb 2008 11:18:49 +0000 (11:18 +0000)
committerChristian Heimes <christian@cheimes.de>
Thu, 28 Feb 2008 11:18:49 +0000 (11:18 +0000)
Modules/itertoolsmodule.c

index 4efde75b62804b97a29bc92c86c9ca7914540779..2ee947dcffa211cdb60ad9bb7d35ade485c0c0ae 100644 (file)
@@ -2111,8 +2111,11 @@ combinations_next(combinationsobject *co)
                        }
                        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). */