Mark Dickinson <dicki...@gmail.com> added the comment:

> `operator` seems a slightly odd place for this.

Yes, it's not ideal. It's by analogy with operator.index, which provides the 
equivalent duck-typing for integers, and calls __index__.  Similarly, 
operator.as_float is primarily there to call __float__, except that now that 
PyFloat_AsDouble also makes use of __index__, it'll call that, too.

My other thought was putting this in math, since it's what the math module is 
already doing implicitly to most inputs.

An alternative float constructor could work. Though we then run into the messy 
question of what it should do for float subclasses ...

----------

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

Reply via email to