- #36
PeterDonis
Mentor
- 47,591
- 23,863
harborsparrow said:I would expect languages such as Python DO create, or at least cache, machine code for parts of a program that are called repeatedly, such as in a loop.
The standard C implementation of Python, CPython, does not do this. PyPy does some just-in-time (JIT) compiling during program execution.
harborsparrow said:Python may or may not be fast enough for scientific applications
The numpy and scipy packages are specifically designed using C extensions for the computation intensive parts of the code, to avoid this problem.
harborsparrow said:One need not declare the types of variables, and Python makes assumptions as to what the type will be.
This is not correct. "Variables" in Python are not objects; they are namespace bindings, which is why no types need to be declared for them. (Recent versions of Python allow type hints, but those are ignored at run time by the interpreter; they are there to help with code clarity for programmers and to help with certain code analysis and review tools.) All objects in Python have well-defined types, which are determined when the objects are constructed; there is no ambiguity whatever about the type of any object in Python, and the interpreter does not have to "make assumptions" about what any object's type will be; the language syntax determines that unambiguously for all built-in types, and the programmer does it for user-defined types by choosing what type's constructor to call in the code.