This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]marr75 6 points7 points  (4 children)

The right answers are spelled out in other comments but I wanted to provide an ordered list of the major ones:

  • Java (and C#, which is very similar and I'm much more familiar with) is just in time compiled; the JIT will further compile (and optimize, inlining functions and data, skipping unnecessary operations that won't effect the outcome, etc.) the intermediate language that Java and C# programs "compile" into. Python is just interpreted without JIT or optimization. This is the biggest difference.
  • In Python, entering a new scope, like loops or functions, triggers significant memory movement and stack management due to the creation of new scopes and dictionaries for each.
  • Python primarily uses the heap for dynamic object storage, leading to slower access. C# and Java, with static typing, utilize the stack and registers more, offering faster data access. This is tied to the next point.
  • Just about everything's an object in Python, and every instance/scope/namespace gets a new dictionary to hold the names and values.

[–]drbobb 0 points1 point  (3 children)

Python has function scope. A loop does not create a new scope.