用rust编写的快速路径操作模块

fpath的Python项目详细描述


路径

用rust编写的python的os.path模块

要求

$ pip install setuptools_rust
$ rustup default nightly

安装

$ pip install --upgrade git+https://github.com/hhatto/fpath

用法

>>>importos.path>>>importfpath>>>os.path.abspath("path/to/file")'/home/user/path/to/file'>>>fpath.abspath("path/to/file")'/home/user/path/to/file'>>>importtimeit>>>timeit.timeit('import os.path;os.path.abspath("path/to/file")',number=1000*10)0.20972810598323122>>>timeit.timeit('import fpath;fpath.abspath("path/to/file")',number=1000*10)0.12387347500771284>>>

基准

methodname              %        real[p,r]        user[p,r]        sys[p,r]       n
abspath            45.53%   10.15s,  5.53s    6.86s,  2.81s   3.25s,  2.69s  100000
basename           53.52%    0.71s,  0.33s    0.70s,  0.33s   0.00s,  0.00s  100000
dirname            57.43%    1.02s,  0.43s    1.01s,  0.43s   0.00s,  0.00s  100000
isabs              56.55%    0.59s,  0.25s    0.59s,  0.25s   0.00s,  0.00s  100000
islink              0.25%    3.78s,  3.77s    0.01s,  0.01s   0.01s,  0.00s      50
exists              0.25%    3.78s,  3.77s    0.01s,  0.01s   0.01s,  0.00s      50
lexists             0.70%    3.77s,  3.74s    0.01s,  0.01s   0.01s,  0.00s      50
split              53.85%    1.17s,  0.54s    1.17s,  0.54s   0.00s,  0.00s  100000
splitext           62.02%    1.22s,  0.46s    1.21s,  0.46s   0.00s,  0.00s  100000
relpath            52.97%    0.02s,  0.01s    0.01s,  0.01s   0.01s,  0.00s      50
normpath           57.27%    2.02s,  0.86s    2.01s,  0.86s   0.00s,  0.00s  100000
realpath            1.08%   13.39s, 13.25s    0.05s,  0.02s   0.02s,  0.03s      50
join               23.01%    0.24s,  0.19s    0.24s,  0.18s   0.00s,  0.00s  100000
expanduser         67.45%    1.50s,  0.49s    1.49s,  0.48s   0.00s,  0.00s  100000
expandvars         61.37%    1.21s,  0.47s    1.19s,  0.47s   0.00s,  0.00s  100000

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

推荐PyPI第三方库


热门话题
java如何向xsi:nil元素添加另一个属性?   Java抽象泛型方法,使用具体类型实现通配符   java使用pcap4j截断pcap文件   当我放置字母a、b和c时,java中的异常预期会下降   java设置活动对话框不可取消   接口类型变量上的Java克隆   使用Java或BouncyCastle对CSR(证书签名请求)进行安全解码/读取   java调用SavingsAccount对象上的函数并打印结果   java如何在Android应用程序上显示地图上的兴趣点(POI)并与之交互?   如果在JavaFX中的ResultSet中未找到任何内容,则显示java警报   java我将springboot和@component与@scheduled一起使用,它每12小时锁定一次   ApachePOI如何使用java删除包含字符串的word表的行   java如果对象(x,y)靠近其他对象(x,y)   从未对JMSException调用java JMS CachingConnectionFactory OneException方法   javascript使用java将HTML页面转换为MS word