当前位置:网站首页>[backtrader source code analysis 4] use Python to rewrite the first function of backtrader: time2num, which improves the efficiency by 2.2 times
[backtrader source code analysis 4] use Python to rewrite the first function of backtrader: time2num, which improves the efficiency by 2.2 times
2022-07-03 04:56:00 【Yunjinqi】
The first time is always difficult , After stepping through many pits , Finally rewrite the first function time2num 了 , Efficiency has probably improved 2.2 times .
run 100000 Time , The cycle time is :0.0006515979766845703,cython Time consuming :0.012257814407348633,python The time spent is :0.027143001556396484, Calculate the multiple of partial promotion :2.214342675976893
run 1000000 Time , The cycle time is :0.006658792495727539,cython Time consuming :0.1207892894744873,python The time spent is :0.2682640552520752, Calculate the multiple of partial promotion :2.2209258488000048
run 10000000 Time , The cycle time is :0.06927633285522461,cython Time consuming :1.201690673828125,python The time spent is :2.6850152015686035, Calculate the multiple of partial promotion :2.2343646830637174
It is not a particularly high efficiency improvement , But on the whole, it is acceptable .
Implementation process
- stay backtrader/utils Under the folder , To build a cython_func.pyx Used to save the files that need to be compiled cython Code
- stay backtrader/utils Under the folder , Write a setup.py, Use
python setup.py build_ext --inplaceCompile - After compilation , Use
python test_time2num.py
cython_func.pyx Code
from cpython.datetime c边栏推荐
- Do you know UVs in modeling?
- 逆袭大学生的职业规划
- Distinguish between releases and snapshots in nexus private library
- [SQL injection] joint query (the simplest injection method)
- [PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing
- 1107 social clusters (30 points)
- Market status and development prospect prediction of global fermentation acid industry in 2022
- The process of browser accessing the website
- JDBC database operation
- Market status and development prospect prediction of the global fire extinguisher industry in 2022
猜你喜欢

Review the configuration of vscode to develop golang

"Niuke brush Verilog" part II Verilog advanced challenge

Analysis of proxy usage of ES6 new feature

Thesis reading_ ICD code_ MSMN

Learn to use the idea breakpoint debugging tool

ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)

The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge

移动端——uniapp开发记录(公共请求request封装)

论文阅读_清华ERNIE

MPM model and ab pressure test
随机推荐
Network security textual research recommendation
Thesis reading_ Chinese NLP_ ELECTRA
Learn to use the idea breakpoint debugging tool
移动端——uniapp开发记录(公共请求request封装)
[tools run SQL blind note]
Notes | numpy-11 Array operation
带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
文献阅读_基于多模态数据语义融合的旅游在线评论有用性识别研究(中文文献)
Web security - CSRF (token)
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
Market status and development prospect prediction of the global fire hose industry in 2022
Current market situation and development prospect forecast of the global fire boots industry in 2022
The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
Truncated sentences of leetcode simple questions
1110 complete binary tree (25 points)
Do you know UVs in modeling?
Handler understands the record
The simple problem of leetcode: dismantling bombs
Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis