Re: [Cython] getting rid of the PY_NEW() hack
Hi Lisandro,
thanks for the feed-back.
I should note that I actually consider the current implementation also a
bit of a hack. The right place to implement this would be as part of the
builtin 'type' object, so that we could more easily support efficient
references to __new__, __init__, __call__, __add__, etc. But I think what's
there now will make life easier for users, as they no longer have to keep
header files around to do this. I'll be very happy if this can be ripped
back out in favour of a more general solution, but until then, it'll do its
job IMO.
Lisandro Dalcin, 31.10.2009 21:43:
> On Sat, Oct 31, 2009 at 10:18 AM, Stefan Behnel wrote:
>> I think this is safe, but I wanted to mention it here so that others can
>> give it another bit of thought.
>
> Stefan, could you cythonize the line below:
>
> cdef str s = str.__new__(str)
>
> In the generated C code you will see a superfluous check "if(str is
> None): raise TypeError()" ... Can you figure out why this is
> happening?
Well, the above is also part of the tests, so I actually know that this is
happening - and I even know why! :)
The problem is that I wasn't sure how to figure out that a variable refers
(Continue reading)