Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Cython - Python at the Speed of C

#1
I use Python almost religiously for anything I can get away with. It's honestly *almost* the perfect language. It's easy to write and read (and clean and concise), works on any platform without compiling specifically, has libraries that are perfect for almost anything, and is installed (or easy to install) almost everywhere. 

The problem with Python is that, boy oh boy, if it isn't slow... And I do a lot of scientific computing with it. It's not acceptable to spend 5 seconds just to rotate one image. 

So I found Cython. It's one of numerous attempts to make Python significantly faster. Unlike some of the other options, Cython somewhat requires some custom modifications to the underlying code (namely declaring C data types). This is not required. It will compile without a hitch if you forget them, so it's easy to retrofit old code. However, you throw away a lot of the performance benefits if you don't declare the types. 

I find that it's quite a bit faster than PyPy (another good alternative to the standard Python interpreter that uses just-in-time compilation). Cython is almost a language of its own because it requires certain modifications, but it's literally the ease of Python with the speed of C, and I don't think you can get much better than that. 

The only downside? You have to compile for every architecture...

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python programmers? Darth-Apple 20 19,291 November 16th, 2020 at 6:02 AM
Last Post: tc4me
  Recursive Sequence of Death [Python] Darth-Apple 7 10,250 April 19th, 2019 at 3:39 PM
Last Post: bestforums



Users browsing this thread: 1 Guest(s)

Dark/Light Theme Selector

Contact Us | Makestation | Return to Top | Lite (Archive) Mode | RSS Syndication 
Proudly powered by MyBB 1.8, © 2002-2024
Forum design by Makestation Team © 2013-2024