Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 34571:e67b587fed77 legacy-trunk
Have set conversion replace existing constant if not used elsewhere.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Wed, 09 Feb 2005 21:24:51 +0000 |
| parents | cd04f2d18a6f |
| children | 369e8e71ea33 |
line wrap: on
line diff
--- a/Python/compile.c Wed Feb 09 21:03:47 2005 +0000 +++ b/Python/compile.c Wed Feb 09 21:24:51 2005 +0000 @@ -570,7 +570,13 @@ return 0; } - /* Append new constant onto consts list.*/ + /* Append new constant onto consts list or replace existing constant + if there are no other references to it.*/ + if (constant->ob_refcnt == 1) { + PyList_SET_ITEM(consts, arg, newconst); + Py_DECREF(constant); + return 1; + } len_consts = PyList_GET_SIZE(consts); if (PyList_Append(consts, newconst)) { Py_DECREF(newconst);
