当前位置:网站首页>[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 --inplace
Compile - After compilation , Use
python test_time2num.py
cython_func.pyx Code
from cpython.datetime c
边栏推荐
- Current market situation and development prospect prediction of global direct energy deposition 3D printer industry in 2022
- [PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing
- Do you know UVs in modeling?
- String matching: find a substring in a string
- C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
- [XSS bypass - protection strategy] understand the protection strategy and better bypass
- Leetcode simple question: the key with the longest key duration
- The process of browser accessing the website
- Mobile terminal - uniapp development record (public request encapsulation)
- [tools run SQL blind note]
猜你喜欢
STM32 reverse entry
MediaTek 2023 IC written examination approved in advance (topic)
联发科技2023届提前批IC笔试(题目)
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
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
Symbol of array element product of leetcode simple problem
ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
Games101 Lesson 9 shading 3 Notes
逆袭大学生的职业规划
Retirement plan fails, 64 year old programmer starts work again
随机推荐
[PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing
Market status and development prospect prediction of the global forward fluorescent microscope industry in 2022
I've seen a piece of code in the past. I don't know what I'm doing. I can review it when I have time
Leetcode simple question: check whether two string arrays are equal
[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology
Handler understands the record
Market status and development prospects of the global automatic tea picker industry in 2022
Oracle SQL table data loss
Review the old and know the new: Notes on Data Science
Compile and decompile GCC common instructions
Esp32-c3 learning and testing WiFi (II. Wi Fi distribution - smart_config mode and BlueIf mode)
Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip
Thesis reading_ Tsinghua Ernie
2022-02-11 daily clock in: problem fine brush
[XSS bypass - protection strategy] understand the protection strategy and better bypass
Introduction to JVM principle
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
1111 online map (30 points)
并发操作-内存交互操作