python的更快关键字字符串替换

nimformat的Python项目详细描述


#nimformat

nimformat库是使用优秀的nimpy模块(对于很棒的nim编程语言)为python创建测试库的实验结果。我们的目标是学习nim,nimpy,创建本机python模块,看看如果有的话,可以实现速度提升。

`nim_sub()`函数是字符串替换的基本实现,其方式类似于python如何为其'string.format()'接受字典。


nim本机python库可以通过发出以下命令来构建。

`nim c--threads:on--app:lib--out:nimformat.pyd--tlsemulation:off nimformat.nim`

注意:这是使用最新的nim开发版本完成的,在编写本文时nim为0.19.9。

详见“test_nimformat.py”。
```
pure python time:1.7126781147680623e-05
pure python[no locals()]time:1.892960021585533e-05
nim dylib time:0.2829040771053697
nim dylib[no locals()]time:0.001650180387713205
nim dylib sub:0.2993304322116857517
nim dylib-sub-multi[no localos()]time:0.00078484848482334343464746
``






例如1:
```
impimpnimformat

variabl2='variabl2='contains'

dictsub=dict(localos())
dictsub={str(key):str(dictsub[key]:str dictsub dictsub(dictsub[key])dictsub“不在”str(key)}


strwithsubstitutions

这是一个{variable1}变量,它跨越多行{variable2}多个
替换。





`



>例如2:
````````
` ` `>'variable1':'string',
'variable2':'包含'
}


strwithsubstitutions'”
这是一个{variable1},它跨越
多行和{variable2}多个
替换。


````


欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
带有本地和在线数据库的java桌面应用程序   corePoolSize=0的java ScheduledThreadPoolExecutor会在一个CPU内核上产生100%的负载   Java打印2D数组,就像带边框的表格一样   优化有没有办法通过方法回调在代码中捕获Java中的对象分配?   java为什么我的变量不能工作?   jface树项上的java刷新存在绘制问题   内存管理在Java中如何在一行中返回数组?   java向云端点添加参数会导致404 GoogleJsonResponseException   java如何定义webservice端点url   来自play store的安卓 AdneEngine错误:java。lang.NoSuchMethodError   java是否可以在Gluon移动应用程序中加载网页?   java Maven OSGi项目已编译,但不会运行   java如何修复布局抖动?   xml Java SoapMessage添加空命名空间   在Java中从派生类调用基类构造函数   java使用netbeans从jtable中的mysql检索数据   使用FIPS 1402库在Java中创建OpenPGP消息的加密   java编程语言的第二个实现可以用这种语言编写吗?   java如何使用带多个参数的分隔符