summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-02-28 11:18:49 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-02-28 11:18:49 (GMT)
commitcdddf187685cde1b2dba3d37aa180191bc254e58 (patch)
tree40a8b80e46351cde213814fa80beb6e7e4c15e3d
parent18750ab2a052f3d7b26b5140744d73186f9fd34f (diff)
downloadcpython-cdddf187685cde1b2dba3d37aa180191bc254e58.zip
cpython-cdddf187685cde1b2dba3d37aa180191bc254e58.tar.gz
cpython-cdddf187685cde1b2dba3d37aa180191bc254e58.tar.bz2
The empty tuple is usually a singleton with a much higher refcnt than 1
-rw-r--r--Modules/itertoolsmodule.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 4efde75..2ee947d 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). */