Lisandro Dalcin wrote:
> On Fri, Apr 17, 2009 at 10:09 AM, Stefan Behnel wrote:
>> ... and that's a feature request, it would be nice to make that work.
>> Could you create two tickets for those?

What I meant was: add support for setting special methods by assignment,
at least in some cases. I didn't specifically mean "__int__" and
"__long__".


> Mmm... we will have to have care here... In Py3k, nb_long was renamed
> to nb_reserved (moreover, now it is a bare void* pointer).

Yes, they removed all sorts of stuff (and I lobbied for removing all sorts
of dead meat), but they forgot to remove that one in time. It's still in
3.1a1.


> So, In
> Py3k, if a class only defines one of __int__() or __long__(), Cython
> should generate code filling the 'nb_int' slot,

Sure.


> and put a NULL in 'nb_reserved'.

Always in Py3.


> What I do not know is what to do
> if a class defines both special methods...

Good question. I think if __long__ is defined, that's what best resembles
nb_int in Py3. People are more likely to expect C-int compatibility in
__int__, so the only reason why one would define __long__ is to pass
larger numbers.

If both are defined, I'd vote for using __long__ in Py3.


> Also note that the in implementation of __Pyx_PyNumber_Int() (from my
> patch for C-int conversion), "nb_long" takes precedence over "nb_int"
> in Python 2. IMHO, that was the best thing to do...

What's CPython doing here?

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to