[Python-ideas] Faster PyArg_ParseTupleAndKeywords kwargs

dw+python-ideas at hmmz.org dw+python-ideas at hmmz.org
Sat May 24 03:52:11 CEST 2014


On Sat, May 24, 2014 at 11:36:29AM +1000, Nick Coghlan wrote:

> 1. Add introspection metadata to functions implemented in C without further
> reducing maintainability (adding an arg to a C function already touched 6
> places, signature metadata would have been a 7th)

> As Nathaniel noted, once checked in, Argument Clinic code is just ordinary C
> code with some funny comments, so it introduces no additional build time
> dependencies.

Hadn't realized it was already in use! It isn't nearly as intrusive as I
might have expected, it seems 'preprocessor' is just a scary word. :)


> 2. Eventually switch the generated code to something faster than
> PyArg_ParseTupleAndKeywords.

> What phase 2 actually looks like hasn't been defined yet (enabling phase 1
> ended up being a big enough challenge for 3.4), but the ideas in this thread
> would definitely be worth exploring further in that context.

The previous mail's hint led to thinking about how to actually implement
a no-API-changes internal cache for PyArg_ParseTupleAndKeywords. While
not a perfect solution, that approach has the tremendous benefit of
backwards compatibility with every existing extension.

It seems after 20 years' evolution, getargs.c is quite resistant to
change (read: it afflicts headaches and angst on the unweary), so
instead I've spent my Friday evening exploring a rewrite.


David


More information about the Python-ideas mailing list