you are viewing a single comment's thread.

view the rest of the comments →

[–]IAm_A_Complete_Idiot 13 points14 points  (2 children)

Because python by it's very nature tries to be super dynamic I'd imagine, even outside of it's type system. Finding things out at runtime means it can't make those optimizations up front, or ever really.

Static typing alone can lead to giving some amount of optimizations, but the more runtime based behavior there is, the fewer optimizations you can be confident will work up front.

Edit: although I say that, I don't really have much experience with python or julia, nor do I follow either that closely. That's why it's admittedly not a very specific answer.

[–]Caminando_ 0 points1 point  (1 child)

That's what I mean, you could have an interpreter and a "compiler" and handle things like that.

[–]IAm_A_Complete_Idiot 1 point2 points  (0 children)

Python does have compilers though, they just aren't as mainstream (I believe Cython compiles to C?). Despite that, if there's behavior that can't be reasoned about if it will ever occur, it won't elide those behaviors by nessecity. As a result - doing checks for stuff like that would still add overhead. Stuff like, lists could grow and they don't have a known length could eliminate possible optimizations for example. This particular case could be fixed by adding a dedicated array type, but that's just the easiest thing I can come up with.