Small inconsistency between string.split and "".split
Alex Martelli
aleaxit at yahoo.com
Fri Sep 17 09:03:16 EDT 2004
Michael Hudson <mwh at python.net> wrote:
> aleaxit at yahoo.com (Alex Martelli) writes:
>
> > Having ALL C-coded functions and methods that accept any argument
> > accept keyword-style arguments in particular would surely lead to a
> > more consistent language,
>
> [...]
>
> This whole area isn't particularly pretty. In general it would be
Indeed, it isn't.
> better to expose more of an extension functions signature *outside*
> the function, for efficiency, introspection and even things like
...and consistency with the way Python-coded functions work.
> psyco. METH_O, METH_NOARGS are a step in this direction -- but you
> can't pass a keyword argument to a METH_O function (not that one would
> want to, very often, but it's still a potential inconsistency).
Right; it could be remedied by letting a macro otherwise equivalent to
METH_O know about that one argument's name.
> I wonder what Pyrex does...
for:
def example(aa, bb):
pass
it generates (name mangling apart, I'm demangling for legibility):
static PyObject* example(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *aa = 0;
PyObject *bb = 0;
static char *argnames[] = {"aa", "bb", 0};
if(!PyArg_ParseTupleAndKeywords(args,kwds,"OO",argnames,&aa,&bb))
return 0;
etc, etc, and METH_VARARGS|METH_KEYWORDS in the PyMethodDef array. IOW,
nothing strange, and all correct, it seems to me.
Alex
>
> My thoughts on this area, like many others, can probably be summarized
> as "I hate C".
>
> Cheers,
> mwh
More information about the Python-list
mailing list