On 22/12/19 9:04 am, Soni L. wrote:
switch (op) {
[...]
case OP_TAILCALL: {
adjust_regs();
some_other_stuff();
/* fallthrough */
}
case OP_CALL: {
make_the_call_happen();
break;
}
}
Relying on fall-through in a switch is a micro-optimisation that
may help make things go faster in C, but not so much in Python,
so trying to find a literal translation is probably wrongheaded.
I would be inclined to separate it into two independent cases:
if op == OP_TAILCALL:
adjust_regs()
some_other_stuff()
elif op == OP_CALL:
adjust_regs()
some_other_stuff()
make_the_call_happen()
If the parts being duplicated are more than just one or two
calls as above, I would factor them out into a separate function.
Decoupling the different branches makes the code easier to read
and maintain, and in Python probably doesn't cost anything
significant in performance.
--
Greg
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/TFUP5DGKB4JFL4HU3L7TIEYMZSOPTMLP/
Code of Conduct: http://python.org/psf/codeofconduct/