当前位置:网站首页>[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边栏推荐
- Notes | numpy-10 Iterative array
- 2022-02-12 daily clock in: problem fine brush
- Market status and development prospect forecast of global heat curing adhesive industry in 2022
- 1118 birds in forest (25 points)
- Flutter monitors volume to realize waveform visualization of audio
- 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
- Literature reading_ Research on the usefulness identification of tourism online comments based on semantic fusion of multimodal data (Chinese Literature)
- 1114 family property (25 points)
- [research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
- Market status and development prospect prediction of global colorimetric cup cover industry in 2022
猜你喜欢

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

Web security - CSRF (token)

MC Layer Target

Number of 1 in binary (simple difficulty)

Number of uniform strings of leetcode simple problem

论文阅读_中文医疗模型_ eHealth

Uipath practice (08) - selector
![[research materials] 2022q1 game preferred casual game distribution circular - Download attached](/img/13/5a67c5d08131745759fdc70a71cf0f.jpg)
[research materials] 2022q1 game preferred casual game distribution circular - Download attached

Handling record of electric skateboard detained by traffic police

Triangular rasterization
随机推荐
String matching: find a substring in a string
Shell script Basics - basic grammar knowledge
[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology
Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
Source insight garbled code solution
Market status and development prospects of the global autonomous marine glider industry in 2022
Leetcode simple question: check whether the array is sorted and rotated
Sdl2 + OpenGL glsl practice (Continued)
Notes | numpy-10 Iterative array
[research materials] 2021 China's game industry brand report - Download attached
Notes | numpy-09 Broadcast
Caijing 365 stock internal reference: what's the mystery behind the good father-in-law paying back 50 million?
C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
Keepalived热备与HAProxy
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree
并发操作-内存交互操作
Leetcode simple question: check whether two string arrays are equal
Truncated sentences of leetcode simple questions
雇佣收银员(差分约束)