消息 [77967]
This new patch also adds a function named gc.is_tracked() which returns
True if the object is tracked by the GC:
>>> import gc
>>> gc.is_tracked(1)
False
>>> gc.is_tracked([])
True
>>> gc.is_tracked(())
True
>>> gc.is_tracked((0,1))
False
>>> gc.is_tracked((0,"a"))
False
>>> gc.is_tracked((0,[]))
True
>>> gc.is_tracked((0,(1,2)))
False
>>> gc.is_tracked((0,(1,0.55)))
False
>>> gc.is_tracked((0,(1,{})))
True
>>> gc.is_tracked((None, True, False, "a", (1,2,u"z",("another",
"nested", u"tuple")), int))
False
>>> gc.is_tracked(gc)
True
(as you see the empty tuple is considered tracked, this is not important
since it is a singleton anyway) |
|
| 日期 |
用户 |
动作 |
参数 |
| 2008-12-17 15:21:13 | pitrou | 修改 | recipients:
+ pitrou, loewis, collinwinter, gregory.p.smith, Rhamphoryncus |
| 2008-12-17 15:21:13 | pitrou | 修改 | messageid: <1229527273.8.0.177245447541.issue4074@psf.upfronthosting.co.za> |
| 2008-12-17 15:21:13 | pitrou | 链接 | issue4074 messages |
| 2008-12-17 15:21:12 | pitrou | 创建 | |
|