I'd be extremenly surprised if it's optimized, there's too many things to check for the optimization to be possible.
Well, I suppose JVM can be a Python runtime too, but I'm not sure if even JVM has come this far.
Depends on the runtime. I would not be surprised if the python runtime optimized our the declaration. Would have to run actual tests to confirm or refute.
It should be pointed out that it's only more performant across multiple executions within the same memory space. If all you care about is the runtime of one execution, then pyramidka's is almost twice as fast, even when x is 1.
I'd be extremenly surprised if it's optimized, there's too many things to check for the optimization to be possible.
Well, I suppose JVM can be a Python runtime too, but I'm not sure if even JVM has come this far.
Depends on the runtime. I would not be surprised if the python runtime optimized our the declaration. Would have to run actual tests to confirm or refute.
and it's repeated for each function call too! :D
It should be pointed out that it's only more performant across multiple executions within the same memory space. If all you care about is the runtime of one execution, then pyramidka's is almost twice as fast, even when x is 1.
Slightly inefficient to create the dict for each iteration of the comprehension.