On Sat, Jul 7, 2018 at 12:19 AM, Stefan Behnel <stefan...@behnel.de> wrote: > Typically, it's calls with 1 to ~3 positional arguments that occur in > performance critical situations. Often just one, rarely more, and zero > arguments is a fast case anyway. Keyword arguments will always suffer some > kind of penalty compared to positional arguments, regardless of how they > are implemented (at runtime). But they can easily be avoided in many cases, > and anyone designing a performance relevant API that *requires* keyword > arguments deserves to have their code forked away from them. :)
In numpy we do sometimes hesitate to use kwargs, even when we otherwise ought to, because of the slowdown they incur. You're right that there's always going to be some overhead here, and I can't say how important these kinds of optimizations are compared to other things people could be spending their time on. But kwargs do improve readability, and it's nice when we can make readable code fast, so people aren't tempted to obfuscate things in the name of speed. -n -- Nathaniel J. Smith -- https://vorpus.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com