I noticed that some functions inside dictobject.c that call insertdict or PyDict_SetItem do an incref of key and value before the call, and a decref after it. An example is dict_merge. Other functions, such as _PyDict_FromKeys, don't do an incref before.
When an incref of key and value is needed before insertdict and when is not? And why is an incref needed? -- https://mail.python.org/mailman/listinfo/python-list