當前位置: 首頁>>代碼示例>>Python>>正文


Python gc.is_tracked方法代碼示例

本文整理匯總了Python中gc.is_tracked方法的典型用法代碼示例。如果您正苦於以下問題:Python gc.is_tracked方法的具體用法?Python gc.is_tracked怎麽用?Python gc.is_tracked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gc的用法示例。


在下文中一共展示了gc.is_tracked方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_slots

# 需要導入模塊: import gc [as 別名]
# 或者: from gc import is_tracked [as 別名]
def check_slots(self, obj, base, extra):
        expected = sys.getsizeof(base) + struct.calcsize(extra)
        if gc.is_tracked(obj) and not gc.is_tracked(base):
            expected += self.gc_headsize
        self.assertEqual(sys.getsizeof(obj), expected) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_sys.py

示例2: _not_tracked

# 需要導入模塊: import gc [as 別名]
# 或者: from gc import is_tracked [as 別名]
def _not_tracked(self, t):
        # Nested tuples can take several collections to untrack
        gc.collect()
        gc.collect()
        self.assertFalse(gc.is_tracked(t), t) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_tuple.py

示例3: _tracked

# 需要導入模塊: import gc [as 別名]
# 或者: from gc import is_tracked [as 別名]
def _tracked(self, t):
        self.assertTrue(gc.is_tracked(t), t)
        gc.collect()
        gc.collect()
        self.assertTrue(gc.is_tracked(t), t) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_tuple.py

示例4: _not_tracked

# 需要導入模塊: import gc [as 別名]
# 或者: from gc import is_tracked [as 別名]
def _not_tracked(self, t):
        # Nested containers can take several collections to untrack
        gc.collect()
        gc.collect()
        self.assertFalse(gc.is_tracked(t), t) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_dict.py

示例5: test_is_tracked

# 需要導入模塊: import gc [as 別名]
# 或者: from gc import is_tracked [as 別名]
def test_is_tracked(self):
        # Atomic built-in types are not tracked, user-defined objects and
        # mutable containers are.
        # NOTE: types with special optimizations (e.g. tuple) have tests
        # in their own test files instead.
        self.assertFalse(gc.is_tracked(None))
        self.assertFalse(gc.is_tracked(1))
        self.assertFalse(gc.is_tracked(1.0))
        self.assertFalse(gc.is_tracked(1.0 + 5.0j))
        self.assertFalse(gc.is_tracked(True))
        self.assertFalse(gc.is_tracked(False))
        self.assertFalse(gc.is_tracked("a"))
        self.assertFalse(gc.is_tracked(u"a"))
        self.assertFalse(gc.is_tracked(bytearray("a")))
        self.assertFalse(gc.is_tracked(type))
        self.assertFalse(gc.is_tracked(int))
        self.assertFalse(gc.is_tracked(object))
        self.assertFalse(gc.is_tracked(object()))

        class OldStyle:
            pass
        class NewStyle(object):
            pass
        self.assertTrue(gc.is_tracked(gc))
        self.assertTrue(gc.is_tracked(OldStyle))
        self.assertTrue(gc.is_tracked(OldStyle()))
        self.assertTrue(gc.is_tracked(NewStyle))
        self.assertTrue(gc.is_tracked(NewStyle()))
        self.assertTrue(gc.is_tracked([]))
        self.assertTrue(gc.is_tracked(set())) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:32,代碼來源:test_gc.py

示例6: test_non_gc

# 需要導入模塊: import gc [as 別名]
# 或者: from gc import is_tracked [as 別名]
def test_non_gc(self):
        with SimpleBase.test():
            s = NonGC()
            self.assertFalse(gc.is_tracked(s))
            ids = [id(s)]
            del s
            gc.collect()
            self.assert_del_calls(ids)
            self.assert_survivors([])
            gc.collect()
            self.assert_del_calls(ids)
            self.assert_survivors([]) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:14,代碼來源:test_finalization.py

示例7: test_non_gc_resurrect

# 需要導入模塊: import gc [as 別名]
# 或者: from gc import is_tracked [as 別名]
def test_non_gc_resurrect(self):
        with SimpleBase.test():
            s = NonGCResurrector()
            self.assertFalse(gc.is_tracked(s))
            ids = [id(s)]
            del s
            gc.collect()
            self.assert_del_calls(ids)
            self.assert_survivors(ids)
            self.clear_survivors()
            gc.collect()
            self.assert_del_calls(ids * 2)
            self.assert_survivors(ids) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:15,代碼來源:test_finalization.py

示例8: test_is_tracked

# 需要導入模塊: import gc [as 別名]
# 或者: from gc import is_tracked [as 別名]
def test_is_tracked(self):
        # Atomic built-in types are not tracked, user-defined objects and
        # mutable containers are.
        # NOTE: types with special optimizations (e.g. tuple) have tests
        # in their own test files instead.
        self.assertFalse(gc.is_tracked(None))
        self.assertFalse(gc.is_tracked(1))
        self.assertFalse(gc.is_tracked(1.0))
        self.assertFalse(gc.is_tracked(1.0 + 5.0j))
        self.assertFalse(gc.is_tracked(True))
        self.assertFalse(gc.is_tracked(False))
        self.assertFalse(gc.is_tracked(b"a"))
        self.assertFalse(gc.is_tracked("a"))
        self.assertFalse(gc.is_tracked(bytearray(b"a")))
        self.assertFalse(gc.is_tracked(type))
        self.assertFalse(gc.is_tracked(int))
        self.assertFalse(gc.is_tracked(object))
        self.assertFalse(gc.is_tracked(object()))

        class UserClass:
            pass
        self.assertTrue(gc.is_tracked(gc))
        self.assertTrue(gc.is_tracked(UserClass))
        self.assertTrue(gc.is_tracked(UserClass()))
        self.assertTrue(gc.is_tracked([]))
        self.assertTrue(gc.is_tracked(set())) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:28,代碼來源:test_gc.py


注:本文中的gc.is_tracked方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。