From: Christian Heimes Date: Thu, 28 Feb 2008 11:18:49 +0000 (+0000) Subject: The empty tuple is usually a singleton with a much higher refcnt than 1 X-Git-Tag: v2.6a1~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cdddf187685cde1b2dba3d37aa180191bc254e58;p=thirdparty%2FPython%2Fcpython.git The empty tuple is usually a singleton with a much higher refcnt than 1 --- diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 4efde75b6280..2ee947dcffa2 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -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). */