新聞中心
弱引用對(duì)象
python 支持 “弱引用” 作為一類對(duì)象。具體來說,有兩種直接實(shí)現(xiàn)弱引用的對(duì)象。第一種就是簡(jiǎn)單的引用對(duì)象,第二種盡可能地作用為一個(gè)原對(duì)象的代理。

創(chuàng)新互聯(lián)主營晉中網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,重慶APP開發(fā),晉中h5成都微信小程序搭建,晉中網(wǎng)站營銷推廣歡迎晉中等地區(qū)企業(yè)咨詢
int PyWeakref_Check(ob)
如果 ob 是一個(gè)引用或代理對(duì)象則返回真值。 此函數(shù)總是會(huì)成功執(zhí)行。
int PyWeakref_CheckRef(ob)
如果 ob 是一個(gè)引用對(duì)象則返回真值。 此函數(shù)總是會(huì)成功執(zhí)行。
int PyWeakref_CheckProxy(ob)
如果 ob 是一個(gè)代理對(duì)象則返回真值。 此函數(shù)總是會(huì)成功執(zhí)行。
PyObject *PyWeakref_NewRef(PyObject *ob, PyObject *callback)
Return value: New reference. Part of the Stable ABI.
Return a weak reference object for the object ob. This will always return a new reference, but is not guaranteed to create a new object; an existing reference object may be returned. The second parameter, callback, can be a callable object that receives notification when ob is garbage collected; it should accept a single parameter, which will be the weak reference object itself. callback may also be None or NULL. If ob is not a weakly referencable object, or if callback is not callable, None, or NULL, this will return NULL and raise TypeError.
PyObject *PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
Return value: New reference. Part of the Stable ABI.
Return a weak reference proxy object for the object ob. This will always return a new reference, but is not guaranteed to create a new object; an existing proxy object may be returned. The second parameter, callback, can be a callable object that receives notification when ob is garbage collected; it should accept a single parameter, which will be the weak reference object itself. callback may also be None or NULL. If ob is not a weakly referencable object, or if callback is not callable, None, or NULL, this will return NULL and raise TypeError.
PyObject *PyWeakref_GetObject(PyObject *ref)
Return value: Borrowed reference. Part of the Stable ABI.
返回弱引用對(duì)象 ref 的被引用對(duì)象。如果被引用對(duì)象不再存在,則返回 Py_None。
備注
該函數(shù)返回被引用對(duì)象的一個(gè) borrowed reference。 這意味著應(yīng)該總是在該對(duì)象上調(diào)用 Py_INCREF(),除非是當(dāng)它在借入引用的最后一次被使用之前無法被銷毀的時(shí)候。
PyObject *PyWeakref_GET_OBJECT(PyObject *ref)
Return value: Borrowed reference.
Similar to PyWeakref_GetObject(), but does no error checking.
本文標(biāo)題:創(chuàng)新互聯(lián)Python教程:弱引用對(duì)象
文章路徑:http://www.dlmjj.cn/article/cohcgjh.html


咨詢
建站咨詢
