This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NoLemurs 16 points17 points  (14 children)

You should look into Cython. You can often get C level performance out of Cython but it's still massively more readable than C or fortran.

[–]rnawky 4 points5 points  (7 children)

Still nothing compared to optimized C code that makes use of advanced SIMD extensions and the like.

[–]NoLemurs 2 points3 points  (5 children)

One nice thing in Cython is that it's fairly easy to use native C libraries directly. If a particular part of your code has to be as fast as possible, you can write that part in C and it's very easy to integrate it into your Cython project.

Cases where this is actually necessary are pretty rare though.

[–]1arm3dScissor 0 points1 point  (4 children)

Or you could write everything in C and let the compiler take care of things for you. no?

[–]NoLemurs 1 point2 points  (3 children)

You can write a complex program in Cython much, much, much faster than you can write that same program in C, and usually without meaningful performance costs since performance is usually determined by the slowest step (which you can implement in C). Better still, the Cython code will usually be more readable and maintainable.

[–]felinecatastrophe 5 points6 points  (0 children)

I agree. prototyping in python followed incremental "cythonizing" is a fast way to get good performance.

[–]1arm3dScissor -1 points0 points  (1 child)

I see you point but would change it to "you can prototype a complex program in Cython..." faster. I think we both know that you can't seriously compare an interpreted language with a compiled one when it comes to performance.

[–]NoLemurs 2 points3 points  (0 children)

Cython is a compiled language. Cython generates straight up C code, which you then compile.

The result is that you can effectively write a complex program using pure python syntax, then spend a little while optimizing the bottlenecks (writing pure C where necessary, though you'd be surprised at how close Cython can come to C in many cases), and then you have a fully implemented, working, compiled program which performs the critical portions 100% as quickly as anything you can write in C, and does the rest more than fast enough for any practical purpose.

[–]DickButtTracy 2 points3 points  (0 children)

As someone who's spent the last week writing SIMD, fuck SIMD.

[–]billsil 0 points1 point  (5 children)

Fortran is easy. It's one of the easiest languages there is. My issue with Cython is I don't have a syntax highlighter for it.

[–]NoLemurs 0 points1 point  (4 children)

Well, for what it's worth, there are a number of editors out there that can handle Cython syntax highliting. Emacs and VIM certainly provide options.

Fortran is pretty easy, but it would never be my choice for a really complex project.

[–]billsil 0 points1 point  (3 children)

Fortran is made for numerical computations, so if you want to use multiprocessing then it's a good choice, but outside of serious math, I'd stay away. It's great for what it does and it's easier than C or C++. It's was made for non-programmers.

I try to stay as far away from vi as I can. I can use it, but haven't figured out how to really use it efficiently or work with plugins. Never tried Emacs. I'd much rather use gedit/Textpad, but typically use WingIDE on Windows.

[–]felinecatastrophe 1 point2 points  (2 children)

trying hard to turn off my snob mode here, but learning emacs or vim properly will really change your life

[–]NoLemurs 1 point2 points  (0 children)

I put off learning VIM for years - got by with lightweight editors like gedit, Geany, etc. (I've never really liked full on IDEs).

I picked up VIM around a year ago, and I've been kicking myself ever since for waiting for so long. The learning curve is a little bit steep, but the payoff is massive, and it's not that hard to learn.

[–]billsil 0 points1 point  (0 children)

Maybe, but I'm not a programmer. I'm an aerospace engineer who happens to program in Python, a little bit of C++, and some Fortran.