cannot use keyword for single required argument
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Cython |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
For methods taking a single required argument, the code generated does not allow one to use keyword to pass the argument. This happens in both 0.9.6.11b and 0.9.6.12.
For example, a method like the following
def setOptObject(self, obj):
self._obj = obj
generates the code below, which clearly cannot handle keyword argument:
static PyObject *__pyx_
PyObject *__pyx_r;
Py_INCREF(
Py_INCREF(
Py_INCREF(
Py_DECREF(
((struct yCTest *)__pyx_
__pyx_r = Py_None; Py_INCREF(Py_None);
Py_DECREF(
Py_DECREF(
return __pyx_r;
}
This is an efficiency issue (Python has special (faster) calling
conventions for one-argument methods). Many of the builtin object
methods don't take keywords either. Perhaps we can make an option
that allows keywords arguments for one-argument methods (although I
don't have a specific case in mind why one would want to use them).
- Robert
On Mar 25, 2008, at 2:58 PM, Felix Wu wrote:
> Public bug reported: pf_1t_7pyCTest_ setOptObject( PyObject __pyx_v_ self); __pyx_v_ obj); __pyx_v_ obj); v_self) ->_obj) ; v_self) ->_obj = __pyx_v_obj; __pyx_v_ self); __pyx_v_ obj); /bugs.launchpad .net/bugs/ 206828
>
> For methods taking a single required argument, the code generated does
> not allow one to use keyword to pass the argument. This happens in
> both
> 0.9.6.11b and 0.9.6.12.
>
> For example, a method like the following
>
> def setOptObject(self, obj):
> self._obj = obj
>
> generates the code below, which clearly cannot handle keyword
> argument:
>
> static PyObject *__pyx_
> *__pyx_v_self, PyObject *__pyx_v_obj) {
> PyObject *__pyx_r;
> Py_INCREF(
> Py_INCREF(
> Py_INCREF(
> Py_DECREF(((struct yCTest *)__pyx_
> ((struct yCTest *)__pyx_
>
> __pyx_r = Py_None; Py_INCREF(Py_None);
> Py_DECREF(
> Py_DECREF(
> return __pyx_r;
> }
>
> ** Affects: cython
> Importance: Undecided
> Status: New
>
> --
> cannot use keyword for single required argument
> https:/
> You received this bug notification because you are a member of Cython-
> dev, which is subscribed to Cython.