3 ms·
Of course in this case there's no FFI involved - the open function is built-in. It's as pure-Python as it can get.
by munch117 3y ago
Of course in this case there's no FFI involved - the open function is built-in. It's as pure-Python as it can get.
- IshKebab 3y agoNot sure I agree there, but anyway in this case the performance had nothing to do with Python being a slow or fast language.
- jwueller 3y agoHow 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.