---
title: "lost on Py_DECREF/INCREF when handling PyList_Append in Python C extension"
author: "standalone"
date: "2015-11-03T21:41:16Z"
tags: []
categories: ["编程语言"]
slug: "lost-on-py-decref-incref-when-handling-pylist-append-in-python-c-extension"
draft: false
lastmod: "2015-11-03T21:41:16Z"
id: 2254238
url: "https://standalone.iteye.com/blog/2254238"
---

The main hint is in the docs, if it says 'Steals a reference' than the function basically takes ownership, if it says 'New Reference' than it did an INCREF for you, if nothing is said it probably does an INCREF and DECREF pair as needed.

<http://stackoverflow.com/questions/10863669/lost-on-py-decref-incref-when-handling-pylist-append-in-python-c-extension>