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

Python psyco.bind函数代码示例

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

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



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


示例16: _psyco_speedup

def _psyco_speedup():
	try:
		import psyco
		psyco.bind(rc4crypt)
		psyco.bind(netstream)
		psyco.bind(nethost)
		psyco.bind(CCLIB)
	except:
		return False
	return True
开发者ID:gavinljj,项目名称:cannon,代码行数:10,代码来源:netstream.py


示例17: accelerate_functions

def accelerate_functions():
    try:
        import psyco
    except ImportError:
        print "Psyco not found.  Some features may run slowly."
        return

    print "Psyco found, accelerating functions."

    import bmh_search
    import behavior

    psyco.bind(bmh_search.BMHSearchForward)
    psyco.bind(bmh_search.BMHSearchBackward)
    import commands.save_and_load
    psyco.bind(commands.save_and_load.compressList)
    psyco.bind(behavior.BehaviorArray)
    psyco.bind(behavior.BehaviorArray._getBlankCommands)
开发者ID:MySheep,项目名称:Archy,代码行数:18,代码来源:pygame_run.py


示例18: __init__

    def __init__(self, primary, matrix, secondary=[]):
        if primary == []:
            raise RunTimeError("No primary columns!")
        if matrix == []:
            raise RunTimeError("No membership matrix")
        self.columns = primary + secondary
        for row in matrix:
            for col in row[:-1]:
                if not col in self.columns:
                    raise ColumnError(col)
        self.nodes = {}
        self.headers = {}
        self.rows = {}
        self.updates = 0
        self.solutions = []

        self.setHeaders(primary, secondary)
        self.readRows(matrix)
        psyco.bind(self.backTrack)
开发者ID:jdolitsky,项目名称:kenken,代码行数:19,代码来源:dance1.py


示例19: UsePsyco

def UsePsyco():
    'Tries to use psyco if it is installed'
    try:
        import psyco
        import elementtree.XMLTreeBuilder as XMLTreeBuilder
        import GCCXMLParser

        psyco.bind(XMLTreeBuilder.fixtext)
        psyco.bind(XMLTreeBuilder.fixname)
        psyco.bind(XMLTreeBuilder.TreeBuilder)
        psyco.bind(GCCXMLParser.GCCXMLParser) 
    except ImportError: pass         
开发者ID:NeoAnomaly,项目名称:xray,代码行数:12,代码来源:pyste.py


示例20: __init__

    def __init__(self, primary, matrix, secondary = []):
        if primary == []:
            raise RunTimeError("No primary columns!")
        if matrix == []:
            raise RunTimeError("No membership matrix")
        self.columns = primary + secondary
        for row in matrix:
            for col in row[:-1]:
                if not col in self.columns:
                    raise ColumnError(col)

        headers = {}                # temporary dict used to construct self.matrix
        self.matrix = []             # "jagged array" of nodes: a list of lists of ones in the matrix 
        self.rows = {}               # symbolic names for the rows, indexed by row number
        self.root = Column()
        self.readColumns(primary, secondary, headers)   # modifies headers
        self.readRows(headers, matrix)                         # initializes self.matrix and self.rows
        self.solutions = []
        self.updates = 0
        psyco.bind(self.backTrack)
开发者ID:rdasxy,项目名称:kenken,代码行数:20,代码来源:dance2.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python psyco.full函数代码示例发布时间:2022-05-25
下一篇:
Python web.setupProxy函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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