简体   繁体   中英

What's python's LOAD_FAST bytecode instruction fast at?

https://docs.python.org/3/library/dis.html#opcode-LOAD_FAST

I have been wondering, why is it specifically named fast and not just "load"?

What alternatives could be used instead that are "slower"?

When are these alternatives used?

All the _FAST opcodes take a variable index to access a local variable. This is fast because it's a simple index into an array rather than a name lookup, which might have to loop through multiple contexts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM