[Python-Dev] Proposing "Argument Clinic", a new way of specifying arguments to builtins for CPython
Antoine Pitrou
solipsis at pitrou.net
Tue Dec 4 10:08:51 CET 2012
Le Mon, 03 Dec 2012 14:29:35 -0800,
Larry Hastings <larry at hastings.org> a écrit :
>
> /*[clinic]
> dbm.open -> mapping
> basename=dbmopen
>
> const char *filename;
> The filename to open.
So how does it handle the fact that filename can either be a unicode
string or a fsencoding-encoded bytestring? And how does it do the right
encoding/decoding dance, possibly platform-specific?
> static char *_keywords[] = {"filename", "flags", "mode", NULL};
>
> if (!PyArg_ParseTupleAndKeywords(args, kwargs,
> "s|si", _keywords,
> &filename, &flags, &mode))
> return NULL;
I see, it doesn't :-)
> But the biggest unresolved question... is this all actually a terrible
> idea?
I like the idea, but it needs more polishing. I don't think the various
"duck types" accepted by Python can be expressed fully in plain C types
(e.g. you must distinguish between taking all kinds of numbers or only
an __index__-providing number).
Regards
Antoine.
More information about the Python-Dev
mailing list