[Python-ideas] Faster PyArg_ParseTupleAndKeywords kwargs

Nick Coghlan ncoghlan at gmail.com
Sat May 24 03:36:29 CEST 2014


On 24 May 2014 06:39, "Nathaniel Smith" <njs at pobox.com> wrote:
>
> On Fri, May 23, 2014 at 9:22 PM,  <dw+python-ideas at hmmz.org> wrote:
> > On Fri, May 23, 2014 at 09:08:28PM +0100, Nathaniel Smith wrote:
> >
> >> You should check out Argument Clinic (PEP 436) if you haven't seen it.
> >
> > Thanks! I'd seen this but forgotten about it. The use of a preprocessor
> > seems excessive, and a potential PITA when combined with other
> > preprocessors - e.g. Qt's moc, but the language is a very cool idea.
>
> Yes, but OTOH it's working and shipping code with a substantial user
> base (lots of the CPython implementation), so making it fast and
> usable in third-party libraries might still be the most efficient
> approach. And IIRC it's not (necessarily) a build-time thing, the
> usual mode is for it to update your checked-in source directly, so
> integration with other preprocessors might be a non-issue.

Note there are two key goals behind Argument Clinic:

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)

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.

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.

Cheers,
Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140524/799517a9/attachment.html>


More information about the Python-ideas mailing list