Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Use Cython.

It's a hassle getting your head around it, and getting it set up, but you'll never look back once you do.

If you rely on PyPy, you get what you're given and then you're stuck. You can't really guess how to rewrite your code to make it faster.

A small blog post I wrote on this: https://honnibal.wordpress.com/2014/10/21/writing-c-in-cytho...

Here's a non-trivial example: https://github.com/honnibal/thinc/blob/master/thinc/learner....

This code is driving a library of very fast NLP tools that I'm writing.



Unforntuately cython is even harder to package up than normal python because it generates one shared library per module.

...not really suitable for games.


You may need to fiddle around with how modules are loaded by Python, but you can do whatever you want with the C files that Cython generates.

kivy-ios should have all the details for building everything into one big Python blob, if that's what you need.


Amen to Cython. When used well (eg. with C types for variables and a few compiler directives, which is not very painful at all), Cython emits code that is extremely similar to idiomatic C for my scientific computing workloads.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: