当前位置: 首页>>代码示例>>Python>>正文


Python sys.grc函数代码示例

本文整理汇总了Python中sys.grc函数的典型用法代码示例。如果您正苦于以下问题:Python grc函数的具体用法?Python grc怎么用?Python grc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了grc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ints

 def test_ints(self):
     i = 42000123
     refcnt = grc(i)
     ci = c_int(i)
     self.assertEqual(refcnt, grc(i))
     self.assertEqual(ci._objects, None)
     return
开发者ID:aevitas,项目名称:wotsdk,代码行数:7,代码来源:testtest_internals.py

示例2: test_X

    def test_X(self):
        class X(Structure):
            _fields_ = [("p", POINTER(c_char_p))]
        x = X()
        i = c_char_p("abc def")
        from sys import getrefcount as grc
        shout "2?", grc(i)
        x.p = pointer(i)
        shout "3?", grc(i)
        for i in range(320):
            c_int(99)
            x.p[0]
        shout x.p[0]
##        del x
##        shout "2?", grc(i)
##        del i
        import gc
        gc.collect()
        for i in range(320):
            c_int(99)
            x.p[0]
        shout x.p[0]
        shout x.p.contents
##        shout x._objects

        x.p[0] = "spam spam"
##        shout x.p[0]
        shout "+" * 42
        shout x._objects
开发者ID:dr4ke616,项目名称:custom_python,代码行数:29,代码来源:test_keeprefs.py

示例3: test_1

    def test_1(self):
        try:
            from sys import getrefcount as grc
        except ImportError:
            return unittest.skip("no sys.getrefcount()")

        f = dll._testfunc_callback_i_if
        f.restype = ctypes.c_int
        f.argtypes = [ctypes.c_int, MyCallback]

        def callback(value):
            #print "called back with", value
            return value

        self.assertEqual(grc(callback), 2)
        cb = MyCallback(callback)

        self.assertGreater(grc(callback), 2)
        result = f(-10, cb)
        self.assertEqual(result, -18)
        cb = None

        gc.collect()

        self.assertEqual(grc(callback), 2)
开发者ID:timm,项目名称:timmnix,代码行数:25,代码来源:test_refcounts.py

示例4: test_1

    def test_1(self):
        from sys import getrefcount as grc

        f = dll._testfunc_callback_i_if
        f.restype = ctypes.c_int
        f.argtypes = [ctypes.c_int, MyCallback]

        def callback(value):
            #print "called back with", value
            return value

        if not test_support.due_to_ironpython_bug("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=22374"):
            self.assertEqual(grc(callback), 2)
        cb = MyCallback(callback)

        if not test_support.due_to_ironpython_bug("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=22374"):
            self.assertTrue(grc(callback) > 2)
        result = f(-10, cb)
        self.assertEqual(result, -18)
        cb = None

        gc.collect()

        if not test_support.due_to_ironpython_bug("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=22374"):
            self.assertEqual(grc(callback), 2)
开发者ID:BillyboyD,项目名称:main,代码行数:25,代码来源:test_refcounts.py

示例5: X_test

    def X_test(self):
        class X(Structure):
            _fields_ = [("p", POINTER(c_char_p))]
        x = X()
        i = c_char_p("abc def")
        from sys import getrefcount as grc
        print("2?", grc(i))
        x.p = pointer(i)
        print("3?", grc(i))
        for i in range(320):
            c_int(99)
            x.p[0]
        print(x.p[0])
##        del x
##        print "2?", grc(i)
##        del i
        import gc
        gc.collect()
        for i in range(320):
            c_int(99)
            x.p[0]
        print(x.p[0])
        print(x.p.contents)
##        print x._objects

        x.p[0] = "spam spam"
##        print x.p[0]
        print("+" * 42)
        print(x._objects)
开发者ID:ChowZenki,项目名称:kbengine,代码行数:29,代码来源:test_keeprefs.py

示例6: test_via

    def test_via(self, vlist=['v',]): # vlist is just to make v unoptimizable
	# Special tests for the via classifier

	
	from sys import getrefcount as grc
	import gc

	iso = self.iso
	hp = self.Use
	d = {}
	k = ('k',)
	v = tuple(vlist) # Make sure v is not optimized to a constant

	d[k] = v
	d[v] = v

	rck = grc(k)
	rcv = grc(v)

	s = iso(v)

	self.assert_( s.byvia.kind == hp.Via("_.f_locals['v']", "_[('k',)]", "_[('v',)]", '_.keys()[1]') or
		      s.byvia.kind == hp.Via("_.f_locals['v']", "_[('k',)]", "_[('v',)]", '_.keys()[0]'))
		      
	del s
	gc.collect()
	gc.collect()
	self.aseq(grc(k), rck)
	self.aseq(grc(v), rcv )
开发者ID:AlekSi,项目名称:guppy-pe,代码行数:29,代码来源:test_Classifiers.py

示例7: X_test

    def X_test(self):

        class X(Structure):
            _fields_ = [('p', POINTER(c_char_p))]

        x = X()
        i = c_char_p('abc def')
        from sys import getrefcount as grc
        print '2?', grc(i)
        x.p = pointer(i)
        print '3?', grc(i)
        for i in range(320):
            c_int(99)
            x.p[0]

        print x.p[0]
        import gc
        gc.collect()
        for i in range(320):
            c_int(99)
            x.p[0]

        print x.p[0]
        print x.p.contents
        x.p[0] = 'spam spam'
        print '+' * 42
        print x._objects
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:27,代码来源:test_keeprefs.py

示例8: test_c_char_p

 def test_c_char_p(self):
     if test_support.due_to_ironpython_bug("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=22374"):
         return
     s = "Hello, World"
     refcnt = grc(s)
     cs = c_char_p(s)
     self.assertEqual(refcnt + 1, grc(s))
     self.assertSame(cs._objects, s)
开发者ID:BillyboyD,项目名称:main,代码行数:8,代码来源:test_internals.py

示例9: test_ints

 def test_ints(self):
     if test_support.due_to_ironpython_bug("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=22374"):
         return
     i = 42000123
     refcnt = grc(i)
     ci = c_int(i)
     self.assertEqual(refcnt, grc(i))
     self.assertEqual(ci._objects, None)
开发者ID:BillyboyD,项目名称:main,代码行数:8,代码来源:test_internals.py

示例10: test_PyObj_FromPtr

 def test_PyObj_FromPtr(self):
     s = 'abc def ghi jkl'
     ref = grc(s)
     pyobj = PyObj_FromPtr(id(s))
     self.assertIs(s, pyobj)
     self.assertEqual(grc(s), ref + 1)
     del pyobj
     self.assertEqual(grc(s), ref)
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:8,代码来源:test_python_api.py

示例11: test_c_char_p

 def test_c_char_p(self):
     if grc is None:
         return unittest.skip("no sys.getrefcount()")
     s = b"Hello, World"
     refcnt = grc(s)
     cs = c_char_p(s)
     self.assertEqual(refcnt + 1, grc(s))
     self.assertSame(cs._objects, s)
开发者ID:Qointum,项目名称:pypy,代码行数:8,代码来源:test_internals.py

示例12: test_ints

 def test_ints(self):
     if grc is None:
         return unittest.skip("no sys.getrefcount()")
     i = 42000123
     refcnt = grc(i)
     ci = c_int(i)
     self.assertEqual(refcnt, grc(i))
     self.assertEqual(ci._objects, None)
开发者ID:ArneBab,项目名称:pypyjs,代码行数:8,代码来源:test_internals.py

示例13: test_PyObj_FromPtr

    def test_PyObj_FromPtr(self):
        s = "abc def ghi jkl"
        ref = grc(s)
        # id(python-object) is the address
        pyobj = PyObj_FromPtr(id(s))
        self.assertTrue(s is pyobj)

        self.assertEqual(grc(s), ref + 1)
        del pyobj
        self.assertEqual(grc(s), ref)
开发者ID:2uller,项目名称:LotF,代码行数:10,代码来源:test_python_api.py

示例14: test_above_30

 def test_above_30(self):
     """Message above 30 bytes are never copied by 0MQ."""
     for i in range(5, 16):  # 32, 64,..., 65536
         s = (2**i)*x
         self.assertEquals(grc(s), 2)
         m = zmq.Frame(s)
         self.assertEquals(grc(s), 4)
         del m
         self.assertEquals(grc(s), 2)
         del s
开发者ID:aelse,项目名称:pyzmq,代码行数:10,代码来源:test_message.py

示例15: test_pyobject

 def test_pyobject(self):
     o = ()
     from sys import getrefcount as grc
     for o in ((), [], object()):
         initial = grc(o)
         self.check_type(py_object, o)
         before = grc(o)
         self.check_type(py_object, o)
         after = grc(o)
         self.assertEqual((after, o), (before, o))
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:10,代码来源:test_callbacks.py


注:本文中的sys.grc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。