4 ms·
Interestingly, I tried rewriting one of my C++ codes in Python one day, using numpy. It was mostly manipulation of largish (~1000 x 1000) matrices. On the upsi
by hugh 18y ago
Interestingly, I tried rewriting one of my C++ codes in Python one day, using numpy. It was mostly manipulation of largish (~1000 x 1000) matrices.
On the upside, it was 100 lines instead of several thousand.
On the downside, it was several hundred times slower.
I didn't bother trying to write serious simulation codes in Python after that.
- riobard 18y agoevery tried NumPy? guess that's what you need for the matrices stuff ...
- ii 18y agoOf course C++ will beat Python in speed if you invest enough time in it. And assembly will beat C/C++ if you invest even more time. My point is that some people assume that if they would just sit and write something in C++ without putting enough time and effort and skill in it, it would be somehow magically faster and better than high-level language, just because it's C++. They are mistaken. Python standard library is extremely fast. For example 'list.sort()' in Pytohn could run 3 times faster than C++ 'sort(vector<string>)'. Here are few examples when simple Python code runs faster than the same code in C++: http://groups.google.com/group/comp.lang.python/browse_thread/thread/70f9bd389473207b/74807f553ae12b8c http://groups.google.com/group/comp.lang.python/browse_threa...
- salaam 18y ago"For example 'list.sort()' in Pytohn could run 3 times faster than C++ 'sort(vector<string>)'" Again comparing apples to oranges.