obriencj / python-sibilant

A dialect of Lisp compiling to Python bytecode
GNU Lesser General Public License v3.0
7 stars 1 forks source link

optimize operations of store/load into dup/store #208

Open obriencj opened 6 years ago

obriencj commented 6 years ago

For operations like

STORE_GLOBAL 5
LOAD_GLOBAL 5

there's some overhead in checking to load the name and dict lookup the value. There's less overhead in LOAD_FAST and LOAD_DEREF but it's still slightly slower than simply DUP the top of stack. We still want to write the value to the relevant location.

DUP_TOP
STORE_GLOBAL 5
obriencj commented 6 years ago

This is similar to the optimization of stripping away LOAD_CONST,POP calls