Making Python parallel: a few points

Making Python parallel: a few points

If you want code to run super quick, you could write it in C++. If you want to code something super quick, you could write it in Python. Is there a middle ground where you can get Python code to execute quickly, without having to go through the process of writing everything in C++? One way to speed up code is to make it run in parallel. With Python, the way to make code truly parallel is to literally kick off new processes, to get around GIL (global interpreter lock) limitations. You can also write specific code bottlenecks in Cython, which is a subset of Python, which is then converted into C code and hence it can be compiled to run quickly. There's also Numba, a LLVM, which can be used to speed up certain Python code. My colleague, Shih-Hau Tan has done work to benchmark various computations using Numba and Dask (which can be seen as a distributed version of pandas). Below I've written a few points to consider when trying to make Python code parallel.

Which libraries can I use to make Python truly parallel?

The simplest library is Python's threading library. Whilst this can speed up tasks which involve a lot of IO blocking, however, for those where we want to do truly parallel processing, as we mentioned, we need to use libraries which work across different processes. In Python these libraries include multiprocessing and several variants (which differ in the way they "pickle" objects inside each process - I have found multiprocess a bit more forgiving...

To read the rest of the article on the Cuemacro website, please click here

You can surely use Cupy (https://github.com/cupy/cupy) for GPU acceleration based on the Numpy syntax, connect your Python interface with Boost.Python and voila! You can see some examples here?https://github.com/dendisuhubdy/boost-python-examples

赞
回复
Jamil Raza

Time series, graphs, causality - modelling & inference.

6 å¹´

If you want to code something super quick and you want it to run super quick as well, why not write it in Julia?

赞
回复
Yasser M.

AI x Investment Research

6 å¹´

The methods you've discussed are usually limited to a single machine, whereas cloud-based approaches can achieve parallelism across multiple machines. For the latter, I typically choose Apache Spark or AWS Lambda, depending on my use case.

赞
回复

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

Saeed Amen的更多文章

  • DeepSeek, objectives and constraints

    DeepSeek, objectives and constraints

    When a new burger joint opens up, there's often a buzz. Everyone (well, at least me) wants to try the new burger.

    1 条评论
  • Hundreds of quant papers from #QuantLinkADay in 2024

    Hundreds of quant papers from #QuantLinkADay in 2024

    I tweet a lot (from @saeedamenfx and at BlueSky at @saeedamenfx.bsky.

  • What we’ve learnt from reading thousands of Fed communications

    What we’ve learnt from reading thousands of Fed communications

    We recently had the last FOMC decision of 2024. Market l participants reacted to the hawkish tone including Powell’s…

    1 条评论
  • Takeaways from QuantMinds 2024 in London

    Takeaways from QuantMinds 2024 in London

    Over the past years, the quant industry has changed substantially. My first visit to Global Derivatives was just over a…

    12 条评论
  • Takeaways from Web Summit 2024

    Takeaways from Web Summit 2024

    Think of Lisbon and no doubt it’ll conjure images of explorers setting sail in centuries past across the ocean, the…

    1 条评论
  • FILS Europe 2024 Takeaways

    FILS Europe 2024 Takeaways

    Paris is home to many things, the Eiffel Tower, the Arc de Triomphe, burgers (ok, I made that one up!). In recent…

    4 条评论
  • Don't look back in hangar steak

    Don't look back in hangar steak

    I'm currently in the queue for Oasis tickets. Rather than mindlessly watching the counter of people in the queue ahead…

    5 条评论
  • The Olympic spirit for forecasting

    The Olympic spirit for forecasting

    The Olympics finally finished, and the Paralympics are about to begin. I managed to go to some of the Olympic football…

  • Eleven years of independence

    Eleven years of independence

    Regrets become ever more edged with the passing of time. Recalling a time long gone, when perhaps a decision made, was…

    5 条评论
  • The human part of machine learning forecasts

    The human part of machine learning forecasts

    I've seen a few videos showing a robot making a burger (here's one of RoboBurger for example). It seems pretty…

    2 条评论

社区洞察

其他会员也浏览了