当前位置:网站首页>[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边栏推荐
- Leetcode simple question: check whether the array is sorted and rotated
- Web security - CSRF (token)
- MC Layer Target
- 【SQL注入】联合查询(最简单的注入方法)
- Retirement plan fails, 64 year old programmer starts work again
- The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
- The simple problem of leetcode: dismantling bombs
- Objects. Requirenonnull method description
- 第十九届浙江省 I. Barbecue
- 移动端——uniapp开发记录(公共请求request封装)
猜你喜欢

Thesis reading_ Chinese NLP_ ELECTRA

Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly

ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation

MediaTek 2023 IC written examination approved in advance (topic)

Number of 1 in binary (simple difficulty)

联发科技2023届提前批IC笔试(题目)

Career planning of counter attacking College Students

Three representations of signed numbers: original code, inverse code and complement code

The least operation of leetcode simple problem makes the array increment
![[USACO 2009 Dec S]Music Notes](/img/e6/282a8820becdd24d63dcff1b81fcaf.jpg)
[USACO 2009 Dec S]Music Notes
随机推荐
MPM model and ab pressure test
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree
The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
Keepalived热备与HAProxy
[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology
Thesis reading_ Chinese medical model_ eHealth
[SQL injection] joint query (the simplest injection method)
Games101 Lesson 9 shading 3 Notes
Truncated sentences of leetcode simple questions
Kept hot standby and haproxy
Esp32-c3 learning and testing WiFi (II. Wi Fi distribution - smart_config mode and BlueIf mode)
Market status and development prospect prediction of global fermentation acid industry in 2022
移动端——uniapp开发记录(公共请求request封装)
112 stucked keyboard (20 points)
Sprintf formatter abnormal exit problem
[XSS bypass - protection strategy] understand the protection strategy and better bypass
M1 Pro install redis
MediaTek 2023 IC written examination approved in advance (topic)
Network security textual research recommendation
Preparation for school and professional cognition