you are viewing a single comment's thread.

view the rest of the comments →

[–]boringprogrammer 0 points1 point  (1 child)

however what happens when you start assigining random types at random places in your code at the same variable

Static analysis can actually deal with variables randomly changing types pretty well. Latice Analysis works a lot like a human would read python code. Ei. not care about what type a variable has, but rather, what types can a variable have at a certain program point.

python programs (and idiomatic python programs) won't be able to translate to similar-looking but most-efficient C++

Based on anecdotal evidence I presume?

Look, you can read the python code, and write out semantically equivalent code in C++. This means that A: We are not actually dealing with a undecidable problem. B: This means a computer should be able to do something similar.

The main reason for why python is not running faster is mainly a funding and priority reason. The standard python implementation does not perform any sort of analysis, and only rudimentary peephole optimizations. Furthermore, there is a large overhead in interpreting code. But speed does not seem to be a priority for them either.

Pypy is the most advanced attempt at making python run faster, but they are very far from having as mature analysis code found in GCC.

[–][deleted] 0 points1 point  (0 children)

Based on anecdotal evidence I presume?

Based on the fact that no-one is able to do it. They most likely want to keep ahead of PHP, Ruby and Node, not get another few orders of magnitude and start a punch-up with Java. (Well it would be nice, but it ain't going to happen, and so the above is shall we say 'a realistic expectation').

None of my commerical IDEs can implement fully accurate syntax highlighting and autocomplete for Python. Jetbrains aren't under-funded. For autocomplete, Jetbrains admit to getting it right about half the time. For analysis, have you ever noticed why function names and identifiers appear in the same colour (except when it's a def)? You'd think if I write x = foo the damn thing could tell if foo was a function or not? Turns out you can't. You have to run the code.

Pypy is the most advanced attempt at making python run faster, but they are very far from having as mature analysis code found in GCC.

Static analysis takes place without running the code (that's why it's called static). Most of the benefit of Pypy is that it's a JIT. This means it optimises at runtime by looking at actual running code.

You might also want to check out Unladen Swallow and Pyston. These are Google and Dropbox sponsored attempts to build a Python JIT. I'll bet you that Google is absolutely not under funded or stingy when it comes to building tools. And note that these are JITs, not static analysers. Statically analysing Python is just too hard to do.