4 ms·
How is it pure Python if it delegates all of the actual work to the Kernel?
by jwueller 3y ago
How is it pure Python if it delegates all of the actual work to the Kernel?
- munch117 3y agoAll I/O delegates to the kernel, eventually. It's pure Python in that there's no cffi, no ctypes, no Cython, no C extensions of any kind.
- int_19h 3y agoIt's pretty hard to draw this line in Python because all built-in types and functions are effectively C extensions, just compiled directly into the interpreter. Conversely, you can have pure C code just using PyObjects (this is effectively what Cython does), with the Python bytecode interpreter completely out of the picture. But the perf improvement is nowhere near what people naively expect from compiled code, usually.
- jwueller 3y agoYes, which is why I would argue that IO is a particularly bad benchmark here, since everything is just a thin layer on top of the actual syscall, and those layers don't do any real work worth comparing. The only thing that makes sense to compare when talking about pythons performance is how many instructions it needs to compute something, versus the instructions needed to compute the same thing in C. Those are probably a few orders of magnitude apart.