• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

which is more useful in the real world? Python or C++...

which is more useful? Python or C++

  • Python

  • C++


Results are only viewable after voting.
On a somewhat related comparison, I ported C++ code to price financial derivatives (options) to Python to get a feeling for relative run-time performance., This is essentially a one-step algorithm in a double nested 'for' loop and random number generators are used in both cases (Mersenne Twister 19937)
Conclusion C++ is 60 times faster!

Just looking at the random number generator part, using Numba improves performance appreciably (Python is 1 1/2 times slower). In more complicated code it is not obvious how to use numba. In this case 'pure' Python would not be suitable for production purposes but it would be useful for prototyping.
60 times faster!!!!
you said it all
 
On a somewhat related comparison, I ported C++ code to price financial derivatives (options) to Python to get a feeling for relative run-time performance., This is essentially a one-step algorithm in a double nested 'for' loop and random number generators are used in both cases (Mersenne Twister 19937)
Conclusion C++ is 60 times faster!

Just looking at the random number generator part, using Numba improves performance appreciably (Python is 1 1/2 times slower). In more complicated code it is not obvious how to use numba. In this case 'pure' Python would not be suitable for production purposes but it would be useful for prototyping.

Did you use Numpy's random library to initialize the random numbers in Python?

I really appreciate Ipython/Jupyter notebook's approach to iterate through a tough problem step by step. Some data structures in python like lists are relatively inefficient compared to say a numpy series. Additionally, vectorizing code to remove for loops helps a lot as well.
 
yes, I used Random indeed and it was faster.
Contrary to the Zen of Python, there are multiple solution to a given problem..

There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
 
"which is more useful in the real world? Python or C++..."

Of course, looking back, the question itself is wrong. Too binary.
 
yes, I used Random indeed and it was faster.
Contrary to the Zen of Python, there are multiple solution to a given problem..

There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.

Sure Numpy isn't part of the standard library - just like Boost isn't. Numpy also takes in tensors and matrices as inputs, so you can apply exponent to an entire matrix for example, while the standard library would fail to do so. So its use case is for scientific computing and therefore it is more powerful (especially the ufuncs) than the standard math library in Python.
 
Having acknowledged Python is great for rapid prototyping, to my mind, practicalities are important. Any large quant shop would have a considerable codebase in C++, especially for performance reasons. Learning C++ therefore would be a good strategy. Also, I feel, C++ supports multiple paradigms and lends itself well to a wide array from problems spanning multiple fields.
 
Last edited:
From "Python in a Nutshell"

"Sometimes, however, you need a deep copy .... fortunately, this need is rare, since a deep copy can take a lot of memory and time."

I don't agree

1. Many applications need deep-fried-copied object
2. Deep copy can be more thread-safe than shallow copy. (replicated objects)

You need both, depending on the context. It is a design pattern.
 
I have no idea of this and one director of a Top 10 quant program told me they are equally useful.
Just wanna see more opinions from people in the field.
That's the correct answer.
The original question is incorrect.
 



Even where systems have been built in Python, a core of code is often built in C++. This is the case, for example, for JPMorgan's Athena pricing engine, and explains why the bank is currently looking for a C++ engineer for its core Athena platform.
I think to some extent python simply sux when it comes to abstraction. It is a great language for data analysis but the language itself is too explicit. I like C++ because of the implicity. Due to exactly that it is easy to write anti-patterns in C++ to fck over my colleagues (just a minor plus LMAO). The main part is really the "linguistic"
 
Back
Top