|
|
|
|
|
by joiguru
3852 days ago
|
|
While I understand the ease of use pure Python provides, I think when manipulating real binary or in memory data, a little bit of C would really simplify and speed things up. Writing raw C extensions can be a pain,
but with Cython or CFFI using C from Python has become extremely easy. |
|
In what sense? Accessing an octet in a buffer and performing basic bitwise operations on it is equivalent:
Reading a buffer in Python is slightly less error-prone, as errors are automatically converted to exceptions, which can be caught at a more centralized location in the code; in C, one must check for errors (and manually propagate those errors) at every read; this applies a bit less in C++, though even there, the stdlib leaves some things to be desired (but generally speaking, they can be wrapped away).Text encoding/decoding, struct packing, and base64 aren't in C or its standard library.
Now, in terms of speed, C wins hands down. (I wrote a minecraft file parser in both C++ and Python, and the difference was several orders of magnitude.)