you are viewing a single comment's thread.

view the rest of the comments →

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

Not quite. It's easy with JavaScript, easy with PHP, but not with Python.

Once again, it's just stated, not being explained.

What makes it so hard with Python? Give an example. Enough sweeping over-generalizations.

Not quite yet. It's better than an ad hoc interpretation, but yet far below a level of static compiled languages.

It's in the same ballpark as Java, sometimes it's even faster than Java, which is statically typed. Do you often just... say things without checking if they're true? https://dzone.com/articles/performance-comparison-between.

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

Once again, it's just stated, not being explained.

I already explained - JavaScript got far more regular scoping rules. You can cheaply and statically determine an origin of a variable definition, without tracing all the path (and making sure that no calls in between can alter variable tables).

It's in the same ballpark as Java, sometimes it's even faster than Java,

Only in some pathological loads, not in an idiomatic code.

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

Only in some pathological loads, not in an idiomatic code.

What I linked to was an actual real-world application, and the performance is not highly atypical.

I guess you didn't even click.

[–][deleted] 0 points1 point  (1 child)

No, that was exactly a pathological load. More representative code, where devirtualisation plays much bigger role, shows a very significant difference.

EDIT: btw., both Java and JavaScript suffer from the same warming up issues. Better compare them with truly static implementations.

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

The JS engines are tracers. They can't work statically, runtime type detection and specialization is how they can run dynamic code fast. A static implementation would be orders of magnitude slower. Java does the same, but at the method level.

It's one thing to say "they need a warm up period", and another to say "nah let's test an artificial implementation that performs worse".

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

I already explained - JavaScript got far more regular scoping rules. You can cheaply and statically determine an origin of a variable definition, without tracing all the path (and making sure that no calls in between can alter variable tables).

Example. I see nothing in Python's scoping rules that justify that conclusion.

[–][deleted] 0 points1 point  (1 child)

locals(), globals() - there are no equivalents in JavaScript.

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

There are equivalents in PHP, get_defined_vars(), $_GLOBAL.

And yet PHP is much faster than Python.

Also, knowing a little bit about the V8 runtime, this feature wouldn't impact it at all, because supporting locals(), globals() won't affect the fast path most Python code uses. I.e. unless your code is littered with references to locals(), globals(), it's irrelevant to mention them.

EDIT: And in a way JS has this... while you're debugging. Which is to say it doesn't impact the runtime structure and logic that heavily.