Stefan Behnel | 18 Jul 2012 09:09
Picon
Favicon

[Cython] code generated for arguments of type "type"

Hi,

the following pull request tries to fix the fact that we currently generate
arguments of type "PyObject*" when someone spells out "type" for them.

https://github.com/cython/cython/pull/126

That's mostly a problem in CPython's C-API, but also in some NumPy
functions. The correct way to translate this would be as a "PyTypeObject*",
not a bare "PyObject*".

Does anyone see a general problem with changing this in the compiler
directly? I'm not sure that it won't break code, for example. We'll at
least have to cast the arguments on the way in as well.

Stefan
Stefan Behnel | 23 Jul 2012 18:43
Picon
Favicon

Re: [Cython] code generated for arguments of type "type"

Stefan Behnel, 18.07.2012 09:09:
> the following pull request tries to fix the fact that we currently generate
> arguments of type "PyObject*" when someone spells out "type" for them.
> 
> https://github.com/cython/cython/pull/126
> 
> That's mostly a problem in CPython's C-API, but also in some NumPy
> functions. The correct way to translate this would be as a "PyTypeObject*",
> not a bare "PyObject*".
> 
> Does anyone see a general problem with changing this in the compiler
> directly? I'm not sure that it won't break code, for example. We'll at
> least have to cast the arguments on the way in as well.

Following up on this: I came to the conclusion that PyTypeObject is really
not what one wants in normal code. Even if a "type" is declared, you still
want a plain object to work with in almost all cases that just happens to
be a type object on top.

That makes the request a pure C-API thing and I think the pull request
handles this quite ok.

Stefan


Gmane