Terry J. Reedy added the comment:

To my understanding, the presence of int.__int__ and float.__float__ are 
implementation issues.  I presume that float(ob) just calls ob.__float__ 
without slowing down for an isinstance(ob, float) check.  Ditto for int(ob).  
The processing for complex(args) and bytes(args) are more complex and currently 
neither call an eponyous method. Would either be improved if it did?

One difference between int and complex, for instance, that might account for 
the internal implementation difference is that the second argument of int can 
only be used with a string first argument, while the second argument of complex 
cannot be used with a string first argument, and must support multiplication by 
1j.  So int.__int__(self) does not allow a second parameter and can (and does) 
just return self.

----------
nosy: +terry.reedy

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

Reply via email to