Mark Dickinson added the comment:

> As I understand, the conclusion of the Python-Dev discussion is that __int__, 
> __float__, __complex__, etc should return exact int, float, complex, not 
> subclasses.

Agreed; that matches my understanding. I'm only observing that it would be 
difficult (and likely undesirable) to actually enforce that `__int__` itself 
always returns an exact int: I'm not sure where that check would/could take 
place, and I'd expect that a direct user-level call to `my_object.__int__` 
probably wouldn't be subject to such a check. What we *can* do is check that 
the result of the `nb_int` call is always an int in the places we use it.

Or we could even go further, and write custom slot_nb_float and slot_nb_int 
functions in Objects/typeobject.c that incorporates those checks. What I don't 
think we can do is check that a *direct* call to `__int__` or `__float__` 
always returns something of the exact type.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26983>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to