Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98680
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Xiang Zhang <18518281186@126.com> |
| Newsgroups | comp.lang.python |
| Subject | What is the meaning of Py_INCREF a static PyTypeObject? |
| Date | Thu, 12 Nov 2015 16:05:09 +0800 |
| Lines | 14 |
| Message-ID | <mailman.257.1447317406.16136.python-list@python.org> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de q//4LU47jR64YI9QTAvvPAAcPY3jVKlkypV/H35SrtlQ== |
| Return-Path | <18518281186@126.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.013 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'static': 0.03; 'api.': 0.04; '<>,': 0.07; 'message-id:@126.com': 0.09; 'python': 0.10; 'missed': 0.15; 'received:io': 0.16; 'received:psf.io': 0.16; 'something.': 0.16; 'struct': 0.22; 'seems': 0.23; 'advance.': 0.23; "haven't": 0.24; 'header:User-Agent:1': 0.26; 'defining': 0.27; 'tutorial': 0.29; 'code': 0.30; 'source': 0.33; 'url:python': 0.33; 'fail': 0.35; 'quite': 0.35; 'skip:p 30': 0.35; 'sometimes': 0.35; 'but': 0.36; 'url:org': 0.36; 'totally': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'received:10': 0.37; 'thanks': 0.37; 'skip:p 20': 0.38; 'someone': 0.38; 'mean': 0.38; 'why': 0.39; 'does': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'url:3': 0.60; 'hope': 0.61; '&': 0.61; 'skip:n 10': 0.62 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Message-ID:Date:MIME-Version; bh=7TCQU CLzps1eCEFrI9rb26Tfie5pwBNg7cTs4T03N3E=; b=UJCXLhkf7dCTDWgmUBNAp 8Uq22FlUmPH3wwR2CPphi8qO1CQldO5U/vVO5KDDeQpE81M5iTmFVonuhonghD5j JCD3GhD0tyt/CgrxgivqgStjAzCGcq0EiAiLqdXdrQ8gkrCR0KuQlSyvWr4YHeNP zgPm+su30LSluCWIX2L69s= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
| X-CM-TRANSID | j9KowABHTxs1SERWdUVMCQ--.30S2 |
| X-Coremail-Antispam | 1Uf129KBjvdXoWrJFy8ury3JryxtFWUJr43Jrb_yoWxWFb_Cr 4fJrykWry3WF4fuF1UGF1fKF4vgwn3uFy8urW5Z3ZFqw1YvrW8Xr1DZr1qya4fJa10ga4q kanrJr18K3WayjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5Vv3UUUUUU== |
| X-Originating-IP | [61.135.152.207] |
| X-CM-SenderInfo | 5dqj4vxu20qiyswou0bp/1tbiHhew-lPguwumHgABs9 |
| X-Mailman-Approved-At | Thu, 12 Nov 2015 03:36:45 -0500 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:98680 |
Show key headers only | View raw
Recently I am learning Python C API. When I read the tutorial <https://docs.python.org/3/extending/newtypes.html#the-basics>, defining new types, I feel confused. After PyType_Ready(&noddy_NoddyType) comes Py_INCREF(&noddy_NoddyType). Actually noddy_NoddyType is a static struct so I don't understand why I need to Py_INCREF it. Since it's Py_INCREFed, does it mean sometimes we also need to Py_DECREF it? But then it seems that type_dealloc will be invoked and it will fail assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); I haven't read the typeobject.c source code totally so I think I must have missed something. But I am quite confused. Hope someone can give me some hints. Thanks in advance.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
What is the meaning of Py_INCREF a static PyTypeObject? Xiang Zhang <18518281186@126.com> - 2015-11-12 16:05 +0800
csiph-web