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

This commit is contained in:
Christian Heimes 2008-02-28 11:18:49 +00:00
parent 18750ab2a0
commit cdddf18768
1 changed files with 5 additions and 2 deletions

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