3 ms·
Can you explain what this means? I know all these words, but it looks like retro-encabulator to me.
by bongodongobob 2y ago
Can you explain what this means? I know all these words, but it looks like retro-encabulator to me.
- pansa2 2y agoWhen one Python function calls another, does that ultimately result in the CPU executing a `call` instruction, or not? Python 3.11 changed from "yes" to "no" for performance reasons. Lua, OTOH, changed from "no" to "yes" in 5.4.0, again for performance. It then changed back to "no" in 5.4.2 for other reasons, despite the performance regression. (In Lua 5.1, instead of call/`return`, `coroutine.resume/yield` is implemented using C-level call/`return`. That would preclude implementing call/`return` the same way - but since 5.2 the coroutine functions are instead implemented via call/`longjmp`.)
- ufo 2y agoAt the heart of the Lua and Python interpreters, there's an evaluation function, written in C, that does something like this: void evaluate() { while (1) { instr = get_next_bytecode_instruction() switch(instr.type) { // run the instruction } } } The question is how to run a CALL bytecode instruction. One way is to use the C stack: call evaluate() recursively. The other way is to have the interpreter maintain its own call stack and the CALL instruction is responsible for updating said call stack. This way the interpreter stays in the same while(1) loop the whole time. Using the C stack can be faster, because you take advantage of the native instruction pointer & return address instead of emulating them in C. But it can also be slower if calling evaluate() is slow.