avalon-fsn Python 编译构造工具开源项目

我要开发同款
匿名用户2019年09月02日
161阅读

技术信息

开源地址
https://gitee.com/umaru_ex/avalon-fsn
授权协议
Mulan

作品详情

avalo-fs

avalo-fs是一个Pytho的编译构造工具,能够将你的代码Cytho

使用avalo-fs的好处代码Cytho化:Widows下把代码编译为pyd,Liux下把代码编译为.so,有效的保护源代码获得性能提升:能够在不做任何代码级别优化的情况下,对Pytho代码进行性能提升安装pipistallavalo-fs编译项目avalo-fs-buildbuild_ext

编译完毕后,对应的文件会在./build/lib*底下

使用编译后的文件avalo-fs-release

执行此命令会把build目录下的编译文件替换到根目录下,仅在编译发布环境使用

##配置文件当有定制参数的时候,可以在项目根目录下新建配置文件avalo-fs.jso

{"remove_models":[],"remove_files":[]}配置名称配置描述remove_models不参与编译的模块remove_files不参与编译的文件性能对比importtimedefru():time_start=time.time()importsysdefmake_tree(depth):ifotdepth:returNoe,Noedepth-=1returmake_tree(depth),make_tree(depth)defcheck_tree(ode):(left,right)=odeifotleft:retur1retur1+check_tree(left)+check_tree(right)mi_depth=4max_depth=max(mi_depth+2,17)stretch_depth=max_depth+1prit("stretchtreeofdepth%d\tcheck:"%stretch_depth,check_tree(make_tree(stretch_depth)))log_lived_tree=make_tree(max_depth)iteratios=2**max_depthfordepthirage(mi_depth,stretch_depth,2):check=0foriirage(1,iteratios+1):check+=check_tree(make_tree(depth))prit("%d\ttreesofdepth%d\tcheck:"%(iteratios,depth),check)iteratios//=4prit("loglivedtreeofdepth%d\tcheck:"%max_depth,check_tree(log_lived_tree))time_ed=time.time()prit('timecost',time_ed-time_start,'s')纯Pythostretchtreeofdepth18check:524287131072treesofdepth4check:406323232768treesofdepth6check:41615368192treesofdepth8check:41861122048treesofdepth10check:4192256512treesofdepth12check:4193792128treesofdepth14check:419417632treesofdepth16check:4194272loglivedtreeofdepth17check:262143timecost11.279994249343872sCytho化stretchtreeofdepth18check:524287131072treesofdepth4check:406323232768treesofdepth6check:41615368192treesofdepth8check:41861122048treesofdepth10check:4192256512treesofdepth12check:4193792128treesofdepth14check:419417632treesofdepth16check:4194272loglivedtreeofdepth17check:262143timecost1.9600331783294678s

简单编译之后,性能直接就提升近6倍

功能介绍

avalon-fsn avalon-fsn 是一个Python的编译构造工具,能够将你的代码Cython 使用avalon-fsn的好处 代码Cython化:Windows下把代码编译为pyd,...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论