Tips and tricks to make Python quicker

Tips and tricks to make Python quicker

Patience is a virtue. We're all used to waiting in line, being patient for our turn to come. The alternative is a lot of squabbling about queue jumpers etc. and would likely result in everyone waiting even longer, whether it's queuing for check in, waiting to be served in a restaurant or so on. Is patience always a virtue though in other areas, in particular in work?

When it comes to coding patience is sometimes a virtue, but more often than not, impatience is more of a virtue to make code faster! Over the past few months since Alexander Denev and I cofounded Turnleaf Analytics, we have been building inflation forecasting models (and indeed if you're interested in our next funding round, let us know)! The research process in has involved many steps, including collecting data, cleaning it and a large amount of prototyping different models in Python. We've been using machine learning as part of the exercise. Training machine learning models can be computationally intensive and hence can take time. After some work, we've managed to speed up the code significantly, which has been incredibly helpful for modelling and reducing computation costs too.

Obviously rewriting everything in C++ could speed it up, but that kind of the defeats the point of using Python in the first place! Whilst it is still a bit of an art to write fast code, there are many types of tips/tricks you can try to help you speed up your code more broadly. Whilst I've written articles like this before, I find that every time I do a new project I find new tricks for speeding up Python! Some of these tricks...

To read the rest of the article, please click here!

Fintan Q.

Financial Technologist with specialization in high-volume and high-speed data.

2 年

Nice post!

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了