当前位置: 首页>>代码示例>>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;未经允许,请勿转载。