3 ms·
The "Python is the language, not the implementation" answer has already been given by @dalke, so I'll answer whether cPython, the implementation of Python that
by mangeletti 11y ago
The "Python is the language, not the implementation" answer has already been given by @dalke, so I'll answer whether cPython, the implementation of Python that Python developers commonly use, is slower than C/C++:
cPython is necessarily slower and uses more memory than C for most tasks, and that's because cPython is implemented in C. You couldn't expect a new programming language that was implemented in Python to be faster than Python, either.
This is less of a concern for scientists and others with very tough performance requirements than it otherwise would be, in part, because cPython code can delegate C and C++ code[0]. This means portions of your program that need to be highly optimized can be implemented in C or C++, while the rest of your program can continue to be written in Python.
[0] https://docs.python.org/3/extending/extending.html https://docs.python.org/3/extending/extending.html
- fauigerzigerk 11y ago>cPython is necessarily slower and uses more memory than C for most tasks, and that's because cPython is implemented in C. You couldn't expect a new programming language that was implemented in Python to be faster than Python, either. You are probably thinking of purely interpreted languages because for compiled languages this is not true. You could write a compiler for a new statically typed language in Python and that language could be orders of magnitude faster than any Python implementation.
- mangeletti 11y agoAh, yes. Good point.