Stefan Monnier <monnier@iro.umontreal.ca> schrieb am So., 2. Juli 2017 um 20:36 Uhr:
> https://github.com/mooz/js2-mode/issues/426#issuecomment-312506855.
> Why is that?

Depends on specifics, so someone would have to investigate. 

I that case the reason was just a dumb mistake on my part: I ran the benchmark without byte-compiled files. With byte compilation lexical binding becomes at least as fast as dynamic binding.


> Shouldn't code compiled with lexical binding be at least as
> fast as code compiled with dynamic binding?

Not necessarily, no.  E.g. when you use `mapcar` and the function
argument has free lexical variables, the lexbind code will have to build
a closure to pass to mapcar.  The access to the lexical vars in the
closure will usually be faster than the corresponding access to those
vars via dynbinding, so if mapcar makes enough calls lexbind can still
be faster, but if mapcar makes few calls, dynbind is faster.


Thanks for the explanation.