emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is lexical binding so slow?


From: Philipp Stephani
Subject: Re: Why is lexical binding so slow?
Date: Mon, 25 Dec 2017 21:20:23 +0000



Stefan Monnier <address@hidden> 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. 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]