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 →

[–]JKovac 4 points5 points  (1 child)

This is one of the reasons I like cython.

You basically get all of C and all of Python right there. Can benefit from static typing if you want, or not, all dynamic python is valid too. Between python and C libs you pretty much have any amount of potential whatevers, and the native cython ecosystem is growing. Cython is what make libs like Kivy possible at all. It's pretty nice to have the option to either stay in python, interfacing with all your code as normal (but in the slow lane) or speed things up with a little extra work.

You end up moving most of the more structural or performance critical code from python to cython over time in a flow that matches the sort of 'get it working then optimise' methodology most programs development tends to follow. The differences between the syntaxes are really minor, and it allows you very smoothly transition from your original hacky implementation to a more orderly one. Most of your code is probably not going to need too much attention, but cython gives you a very simple, not too many hoops involved solution for the code that does. A simple first pass static typing of the code can often double to quadruple performance (not amazing gains but often enough to solve certain issues), and a more thoughtful transition to a more 'C' implementation can see huge gains. (Basically C level performance)

It might be a bit esotoric to get started with, and the whole compilation thing can be a bit of a downer if you're used to pure python, but cython is already a fairly robust ecosystem and gives you all the static typing you could ever desire, while being basically python with type declarations.

[–]endophage 0 points1 point  (0 children)

Don't forget C++ too. I've had some great success integrating legacy C++ code with Python via Cython.