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


Python psyco.bind函数代码示例

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


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

示例1: updateCache

    def updateCache(self):
        # Import Psyco if available and not disabled
        import platform
        if platform.machine() in ['i386', 'i486', 'i586', 'i686']:
            if not self.configuration.disable_psyco:
                try:
                    import psyco
                except ImportError:
                    bb.msg.note(1, bb.msg.domain.Collection, "Psyco JIT Compiler (http://psyco.sf.net) not available. Install it to increase performance.")
                else:
                    psyco.bind( self.parse_bbfiles )
            else:
                bb.msg.note(1, bb.msg.domain.Collection, "You have disabled Psyco. This decreases performance.")

        self.status = bb.cache.CacheData()

        ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or ""
        self.status.ignored_dependencies = Set( ignore.split() )

        self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", self.configuration.data, 1) )

        bb.msg.debug(1, bb.msg.domain.Collection, "collecting .bb files")
        (filelist, masked) = self.collect_bbfiles()
        bb.data.renameVar("__depends", "__base_depends", self.configuration.data)
        self.parse_bbfiles(filelist, masked, self.myProgressCallback)
        bb.msg.debug(1, bb.msg.domain.Collection, "parsing complete")

        self.buildDepgraph()
开发者ID:BackupTheBerlios,项目名称:bitbake-svn,代码行数:28,代码来源:cooker.py

示例2: fbenchmark

    def fbenchmark(f, var=[Symbol("x")]):
        """
        Do some benchmarks with f using clambdify, lambdify and psyco.
        """
        global cf, pf, psyf
        start = time()
        cf = clambdify(var, f)
        print "compile time (including sympy overhead): %f s" % (time() - start)
        pf = lambdify(var, f, "math")
        psyf = None
        try:
            import psyco

            psyf = lambdify(var, f, "math")
            psyco.bind(psyf)
        except ImportError:
            pass
        code = """for x in (i/1000. for i in range(1000)):
        f(%s)""" % (
            "x," * len(var)
        ).rstrip(
            ","
        )
        t1 = Timer(code, "from __main__ import cf as f")
        t2 = Timer(code, "from __main__ import pf as f")
        if psyf:
            t3 = Timer(code, "from __main__ import psyf as f")
        else:
            t3 = None
        print "for x = (0, 1, 2, ..., 999)/1000"
        print "20 times in 3 runs"
        print "compiled:      %.4f %.4f %.4f" % tuple(t1.repeat(3, 20))
        print "Python lambda: %.4f %.4f %.4f" % tuple(t2.repeat(3, 20))
        if t3:
            print "Psyco lambda:  %.4f %.4f %.4f" % tuple(t3.repeat(3, 20))
开发者ID:christinapanto,项目名称:project,代码行数:35,代码来源:compilef.py

示例3: main

def main(n=1000, n_iter=100):
    print "Doing %d iterations on a %dx%d grid" % (n_iter, n, n)
    methods = ["numeric", "blitz", "inline", "fastinline"]
    # 'pyrex',
    #'fortran77', 'fortran90-arrays', 'fortran95-forall']
    for i in methods:
        print i,
        sys.stdout.flush()
        print "took", time_test(n, n, stepper=i, n_iter=n_iter), "seconds"

    print "slow (1 iteration)",
    sys.stdout.flush()
    s = time_test(n, n, stepper="slow", n_iter=1)
    print "took", s, "seconds"
    print "%d iterations should take about %f seconds" % (n_iter, s * n_iter)

    try:
        import psyco
    except ImportError:
        print "You don't have Psyco installed!"
    else:
        psyco.bind(LaplaceSolver)
        psyco.bind(Grid)
        print "slow with Psyco (1 iteration)",
        sys.stdout.flush()
        s = time_test(n, n, stepper="slow", n_iter=1)
        print "took", s, "seconds"
        print "%d iterations should take about %f seconds" % (n_iter, s * n_iter)
开发者ID:beibeiyang,项目名称:Latent-Dirichlet-Allocation,代码行数:28,代码来源:laplace.py

示例4: fbenchmark

 def fbenchmark(f, var=[Symbol('x')]):
     """
     Do some benchmarks with f using clambdify, lambdify and psyco.
     """
     global cf, pf, psyf
     start = time()
     cf = clambdify(var, f)
     print 'compile time (including sympy overhead): %f s' % (time() - start)
     pf = lambdify(var, f, 'math')
     psyf = None
     try:
         import psyco
         psyf = lambdify(var, f, 'math')
         psyco.bind(psyf)
     except ImportError:
         pass
     code = '''for x in (i/1000. for i in xrange(1000)):
     f(%s)''' % ('x,'*len(var)).rstrip(',')
     t1 = Timer(code, 'from __main__ import cf as f')
     t2 = Timer(code, 'from __main__ import pf as f')
     if psyf:
         t3 = Timer(code, 'from __main__ import psyf as f')
     else:
         t3 = None
     print 'for x = (0, 1, 2, ..., 999)/1000'
     print '20 times in 3 runs'
     print 'compiled:      %.4f %.4f %.4f' % tuple(t1.repeat(3, 20))
     print 'Python lambda: %.4f %.4f %.4f' % tuple(t2.repeat(3, 20))
     if t3:
         print 'Psyco lambda:  %.4f %.4f %.4f' % tuple(t3.repeat(3, 20))
开发者ID:gnulinooks,项目名称:sympy,代码行数:30,代码来源:compilef.py

示例5: main

def main(n=500, n_iter=100):
    print "Doing %d iterations on a %dx%d grid"%(n_iter, n, n)
    for i in ['numeric', 'blitz', 'inline', 'fastinline', 'fortran',
              'pyrex']:
        print i,
        sys.stdout.flush()
        print "took", time_test(n, n, stepper=i, n_iter=n_iter), "seconds"

    print "slow (1 iteration)",
    sys.stdout.flush()
    s = time_test(n, n, stepper='slow', n_iter=1)
    print "took", s, "seconds"
    print "%d iterations should take about %f seconds"%(n_iter, s*n_iter)

    try:
        import psyco
    except ImportError:
        print "You don't have Psyco installed!"
    else:
        psyco.bind(LaplaceSolver)
        psyco.bind(Grid)
        print "slow with Psyco (1 iteration)",
        sys.stdout.flush()
        s = time_test(n, n, stepper='slow', n_iter=1)
        print "took", s, "seconds"
        print "%d iterations should take about %f seconds"%\
              (n_iter, s*n_iter)
开发者ID:apetcho,项目名称:SciPy-CookBook,代码行数:27,代码来源:laplace.py

示例6: __init__

 def __init__(self, infile, debug=0, firstblock=None, lastblock=None) :
     """Initialize the generic parser."""
     self.infile = infile
     self.debug = debug
     if firstblock is None :
         self.infile.seek(0)
         firstblock = self.infile.read(FIRSTBLOCKSIZE)
         try :
             self.infile.seek(-LASTBLOCKSIZE, 2)
             lastblock = self.infile.read(LASTBLOCKSIZE)
         except IOError :    
             lastblock = ""
         self.infile.seek(0)
     self.firstblock = firstblock
     self.lastblock = lastblock
     if not self.isValid() :
         raise PDLParserError, "Invalid file format !"
     try :
         import psyco 
     except ImportError :    
         pass # Psyco is not installed
     else :    
         # Psyco is installed, tell it to compile
         # the CPU intensive methods : PCL and PCLXL
         # parsing will greatly benefit from this, 
         # for PostScript and PDF the difference is
         # barely noticeable since they are already
         # almost optimal, and much more speedy anyway.
         psyco.bind(self.getJobSize)
开发者ID:BackupTheBerlios,项目名称:jasmine-svn,代码行数:29,代码来源:pdlparser.py

示例7: psyco_speedup

def psyco_speedup ():
	try:
		import psyco
		psyco.bind(chessboard)
		psyco.bind(evaluation)
	except:
		pass
	return 0
开发者ID:houston563,项目名称:gobang,代码行数:8,代码来源:gobang.py

示例8: test_circular_obj

def test_circular_obj():
    def f1():
        x = Rect(5, 6)
        x.foo = x
        return x
    psyco.bind(f1)
    x = f1()
    assert x.foo is x
开发者ID:JasonAng,项目名称:ResearchScripts,代码行数:8,代码来源:test_compactobject.py

示例9: optimize

	def optimize(self, functions):
		try:
			from psyco import bind
			for function in functions:
				bind(function)
		except ImportError:
			pass
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:8,代码来源:Editor.py

示例10: enable_psyco

def enable_psyco(template_class):
  try:
    import psyco
  except ImportError:
    pass
  else:
    psyco.bind(SpitfireTemplate)
    psyco.bind(template_class)
开发者ID:bekacho,项目名称:spitfire,代码行数:8,代码来源:template.py

示例11: __init__

    def __init__(self, *args):
        self.objimap = None
        apply(mailserver.MailServer.__init__, (self,) + args)

        try:
            # Psyco increase speed about a 40% here...
            psyco.bind(self.get_message)
        except NameError:
            pass
开发者ID:juanjux,项目名称:animail,代码行数:9,代码来源:imap.py

示例12: setup_psyco

 def setup_psyco():
     """ Оптимизировать узкие места в MrdDataSource с помощью psyco """
     try:
         import psyco
         psyco.bind(MrdDataSource._calculate_endings)
         psyco.bind(MrdDataSource._load_lemmas)
         psyco.bind(MrdDataSource._cleanup_endings)
         psyco.bind(MrdDataSource._section_lines)
         psyco.bind(DictDataSource.calculate_rule_freq)
     except ImportError:
         pass
开发者ID:gkrasulya,项目名称:lift-fit.ru,代码行数:11,代码来源:mrd_source.py

示例13: __init__

    def __init__(self, *args):
        self.objpop = None
        self.deleted_msgs = []
        apply(mailserver.MailServer.__init__, (self,) + args)

        try:
            # Psyco increase speed about a 40% here...
            import psyco
            psyco.bind(self.get_message)
        except ImportError:
            pass
开发者ID:juanjux,项目名称:animail,代码行数:11,代码来源:pop3.py

示例14: __init__

    def __init__(
        self,
        redis_host='localhost',
        redis_port=6379,
        redis_db=0,
        ):

        self._REDIS_DELIM = '$'
        self._redis = redis.Redis(host=redis_host, port=redis_port, db=redis_db)

        try:
            import psyco
            psyco.bind(self.resolveUserInfoForKeys)
            print 'Using psyco to compile resolveUserInfoForKeys method'
        except ImportError, e:
            pass  # psyco not installed
开发者ID:ANB2,项目名称:Mining-the-Social-Web,代码行数:16,代码来源:TwitterSocialGraphUtility.py

示例15: test_constant_obj

def test_constant_obj():
    def f1():
        return rect1.w * rect1.h
    def f2(a):
        rect1.w = a
    psyco.bind(f1)
    psyco.bind(f2)
    rect1.w = 6
    rect1.h = 7
    res = f1()
    assert res == 42
    f2(4)
    res = f1()
    assert res == 28
    f2(0.5)
    res = f1()
    assert res == 3.5
开发者ID:Galland,项目名称:nodebox-opengl,代码行数:17,代码来源:test_compactobject.py


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