Keywordargument in string.split

Michael Hudson mwh21 at cam.ac.uk
Thu Jan 27 08:58:09 EST 2000


"P.J.W.S. Vrijlandt" <P.J.W.S.VRIJLANDT at INT.azg.nl> writes:

> I wrote:
> 
> > I have this error I don't quite understand.
> > Why can't I give 'sep' as a keyword argument?
> > 
> > It seems that the string module I import, is not the string.py in the 
> > standard distribution but a not-quite-equivalent c-implementation of 
> > it.
> 
> I got replies pointing to 'strop', which is a c-implementation of 
> string, and is imported by string.py
> 
> But what is the header (def) of split in strop? 
> (and why is it different)

Supporting keyword arguments for C extensions requires a little bit of
work on the part of the extension writer. Not much, but a bit. 

This work doesn't seem to have been done for many modules in the
standard distribution. This could be for two reasons:

1) The support for C extensions taking keyword parameters is quite
   new, and not much has caught up yet (no idea whether this is true)

2) The standard C extensions are so commonly used that people don't
   need to use kwargs (I'd never noticed the lack before).

3) PyArg_ParseTupleAndKeywords is significantly slower than
   PyArg_ParseTuple, even in the no kwarg case (I don't believe this
   is the case, but it's possible).

It seems that sha and parser accept keyword arguments, and nothing
else. Would patches to remedy this be accepted? Looks easy enough to
acheive, if a little tedious.

Cheers,
Michael



More information about the Python-list mailing list