• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python sys.grc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_PyString_FromString

 def test_PyString_FromString(self):
     pythonapi.PyString_FromString.restype = py_object
     pythonapi.PyString_FromString.argtypes = (c_char_p,)
     s = 'abc'
     refcnt = grc(s)
     pyob = pythonapi.PyString_FromString(s)
     self.assertEqual(grc(s), refcnt)
     self.assertEqual(s, pyob)
     del pyob
     self.assertEqual(grc(s), refcnt)
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:10,代码来源:test_python_api.py


示例17: test_refcount

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

        def func(*args):
            pass

        self.assertEqual(grc(func), 2)
        f = OtherCallback(func)
        self.assertGreater(grc(func), 2)
        del f
        self.assertGreaterEqual(grc(func), 2)
        gc.collect()
        self.assertEqual(grc(func), 2)

        class X(ctypes.Structure):
            _fields_ = [('a', OtherCallback)]

        x = X()
        x.a = OtherCallback(func)
        self.assertGreater(grc(func), 2)
        del x
        self.assertGreaterEqual(grc(func), 2)
        gc.collect()
        self.assertEqual(grc(func), 2)
        f = OtherCallback(func)
        self.assertGreater(grc(func), 2)
        f.cycle = f
        del f
        gc.collect()
        self.assertEqual(grc(func), 2)
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:30,代码来源:test_refcounts.py


示例18: test_PyString_FromString

    def test_PyString_FromString(self):
        pythonapi.PyString_FromString.restype = py_object
        pythonapi.PyString_FromString.argtypes = (c_char_p,)

        s = "abc"
        refcnt = grc(s)
        pyob = pythonapi.PyString_FromString(s)
        self.failUnlessEqual(grc(s), refcnt)
        self.failUnlessEqual(s, pyob)
        del pyob
        self.failUnlessEqual(grc(s), refcnt)
开发者ID:15580056814,项目名称:hue,代码行数:11,代码来源:test_python_api.py


示例19: test_PyInt_Long

 def test_PyInt_Long(self):
     ref42 = grc(42)
     pythonapi.PyInt_FromLong.restype = py_object
     self.assertEqual(pythonapi.PyInt_FromLong(42), 42)
     self.assertEqual(grc(42), ref42)
     pythonapi.PyInt_AsLong.argtypes = (py_object,)
     pythonapi.PyInt_AsLong.restype = c_long
     res = pythonapi.PyInt_AsLong(42)
     self.assertEqual(grc(res), ref42 + 1)
     del res
     self.assertEqual(grc(42), ref42)
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:11,代码来源:test_python_api.py


示例20: test_c_char_p

 def test_c_char_p(self):
     s = "Hello, World"
     refcnt = grc(s)
     cs = c_char_p(s)
     self.assertEqual(refcnt + 1, grc(s))
     try:
         # Moving gcs need to allocate a nonmoving buffer
         cs._objects._obj
     except AttributeError:
         self.assertSame(cs._objects, s)
     else:
         self.assertSame(cs._objects._obj, s)
开发者ID:1018365842,项目名称:FreeIMU,代码行数:12,代码来源:test_internals.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sys.intern函数代码示例发布时间:2022-05-27
下一篇:
Python sys.getwindowsversion函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap