Re: What is the meaning of Py_INCREF a static PyTypeObject?

2015-11-13 Thread Oscar Benjamin
On 13 November 2015 at 03:08, Xiang Zhang <18518281...@126.com> wrote: > I think the meaning of Py_INCREF a static type object is to prevent it from > being deallocated when it is Py_DECREFed somehow later. Just as you said, it > may be somehow deallocated when using. > > NoddyType is a static

Re: What is the meaning of Py_INCREF a static PyTypeObject?

2015-11-13 Thread Xiang Zhang
Thanks for your reply jason. Your reply does give me hints and then I read more code and find maybe you are wrong in some points. I think the meaning of Py_INCREF a static type object is to prevent it from being deallocated when it is Py_DECREFed somehow later. Just as you said, it may be

What is the meaning of Py_INCREF a static PyTypeObject?

2015-11-12 Thread Xiang Zhang
Recently I am learning Python C API. When I read the tutorial , defining new types, I feel confused. After PyType_Ready(_NoddyType) comes Py_INCREF(_NoddyType). Actually noddy_NoddyType is a static struct so I don't understand why

Re: What is the meaning of Py_INCREF a static PyTypeObject?

2015-11-12 Thread Jason Swails
On Thu, Nov 12, 2015 at 3:05 AM, Xiang Zhang <18518281...@126.com> wrote: > 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(_NoddyType) comes >