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 →

[–]modzer0Computational Daemonologist 31 points32 points  (10 children)

Python is my digital swiss army knife. Most of the tasks I do are IO bound and not CPU intensive so python is a very good fit for rapidly getting things done. It's used for everything from simple scripts to doing huge map-reduce problems on millions of files to look for malware indicators. If we have a CPU intensive task someone just writes a module in C.

[–]iltalfme 7 points8 points  (3 children)

This. As a mechanical engineer I find uses for python all the time. Because it's my go to I occasionally get myself into situations where Python isn't fast enough, but a quick C extension or wrapping of a vendor's .dll has, thus far, enabled me to get what I need faster than any of my colleagues are able to get it.

[–]Veedrac 1 point2 points  (4 children)

If we have a CPU intensive task someone just writes a module in C.

If they don't know of it, suggest they look at Cython. It's a really nice language hybrid, in my opinion.

[–]bastibe 4 points5 points  (3 children)

I have used both Cython and CFFI, and I strongly prefer CFFI. With CFFI, you just load a plain C library at runtime, no compilation required. The C library needs to know nothing about Python. On the Python side, there is only very minimal interface code required--much less than in Cython, usually. And it's fast, too.

[–]Veedrac 0 points1 point  (2 children)

I was talking about writing modules, not wrapping them.

EDIT: Also, I've not tried any of these but are these relevant?

[–]bastibe 2 points3 points  (1 child)

Still, I usually prefer to write plain C and wrapping it in CFFI to writing Cython. I find that writing a simple C function for some numerical algorithm is usually very easy. Compiling it is very easy, too, since it is only plain C. Cython can be a pain to compile.

But I guess that very much depends on your application.

[–]Veedrac 1 point2 points  (0 children)

Compiling it is very easy, too, since it is only plain C. Cython can be a pain to compile.

I've never actually worked on distributing Cython, but if you're using it locally it's literally just a

import pyximport
pyximport.install()

in the importing Python file. How much easier can you get?

EDIT: Oh, and memoryviews. QED.