Archive for Dezember, 2012

Writing C code is a premature optimisation

Sonntag, Dezember 2nd, 2012

It seems I can’t repeat this often enough. People who write Python wrappers for libraries in plain C “because it’s faster” tend to overestimate their C-API skills and simply have no idea how costly maintenance is. It’s like the old advice about optimisation: Don’t do it! (and, if you’re an expert: Don’t do it yet!). If you write your wrapper code in C instead of Cython, it will be

  • slower
  • less portable
  • harder to maintain
  • harder to extend
  • harder to optimise
  • harder to debug and fix

It will cost you a lot of effort, both short term and long term, that is much better spent in adding cool features and optimising the performance critical parts of your code once you got it working. Say, is your time really so cheap that you want to waste it writing C code?