This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 zach.ware
收信人 mark.dickinson, serhiy.storchaka, zach.ware
日期 2020-05-28.16:01:32
SpamBayes Score -1.0
Marked as misclassified
Message-id <1590681692.85.0.70822612945.issue40801@roundup.psfhosted.org>
In-reply-to
内容
`operator` seems a slightly odd place for this.  My naive expectation would be that `float(floatlike_obj)` should do what you want, but it seems that's not the case (too permissive of input types?).  So then, what about an alternate constructor on the float object, `float.from_floatlike(obj)`?  This could be implemented as effectively:

class float:
    @classmethod
    def from_floatlike(cls, obj):
        return cls(PyFloat_FromDouble(PyFloat_AsDouble(obj)))

which would work to get an instance of any float subclass after a round-trip through a double.  I have no idea whether that's actually useful, though :)
历史
日期 用户 动作 参数
2020-05-28 16:01:32zach.ware修改recipients: + zach.ware, mark.dickinson, serhiy.storchaka
2020-05-28 16:01:32zach.ware修改messageid: <1590681692.85.0.70822612945.issue40801@roundup.psfhosted.org>
2020-05-28 16:01:32zach.ware链接issue40801 messages
2020-05-28 16:01:32zach.ware创建