[Python-Dev] cffi in stdlib

Eli Bendersky eliben at gmail.com
Wed Feb 27 16:50:18 CET 2013


On Tue, Feb 26, 2013 at 11:29 PM, Ronald Oussoren <ronaldoussoren at mac.com>wrote:

>
> On 26 Feb, 2013, at 16:13, Maciej Fijalkowski <fijall at gmail.com> wrote:
>
> > Hello.
> >
> > I would like to discuss on the language summit a potential inclusion
> > of cffi[1] into stdlib.
>
> The API in general looks nice, but I do have some concens w.r.t. including
> cffi in the stdlib.
>
> 1. Why is cffi completely separate from ctypes, instead of layered on top
> of it? That is, add a utility module to ctypes that can parse C
> declarations and generate the right ctypes definitions.
>
> 2. Cffi has a dependencies on pycparser and that module and its
> dependencies would therefore also be added to the stdlib (even if they'd be
> hidden in the cffi package)
>
> 3. Cffi basicly contains a (limited) C parser, and those are notoriously
> hard to get exactly right. Luckily cffi only needs to interpret
> declarations and not the full language, but even so this can be a risk of
> subtle bugs.
>

pycparser has been around for more than 4 years and is pretty stable. I
know that it's been used to parse Windows headers, Linux system headers and
other "scary" things for a C parser to handle. It's only known problem has
to do with over-creative abuses of C's context sensitivity:
http://eli.thegreenplace.net/2011/05/02/the-context-sensitivity-of-c%E2%80%99s-grammar-revisited/

In practice it doesn't come up often, and almost never in declarations,
which is the subset cffi uses pycparser for.

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130227/79ccbfc6/attachment.html>


More information about the Python-Dev mailing list