Message77967
| Author |
pitrou |
| Recipients |
Rhamphoryncus, collinwinter, gregory.p.smith, loewis, pitrou |
| Date |
2008年12月17日.15:21:11 |
| SpamBayes Score |
4.2107683e-07 |
| Marked as misclassified |
No |
| Message-id |
<1229527273.8.0.177245447541.issue4074@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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) |
|