[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-12-15 Thread STINNER Victor
STINNER Victor added the comment: New changeset cb8b946ac10386e6cab1376945f64f683b5b16d3 by Victor Stinner (Batuhan Taşkaya) in branch 'master': bpo-38629: implement __floor__ and __ceil__ for float type (GH-16985)

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-12-15 Thread STINNER Victor
STINNER Victor added the comment: Thanks Batuhan Taşkaya for the implementation, and thanks Ran Benita for the feature request :-) -- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 3.9 ___ Python

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-31 Thread Vedran Čačić
Vedran Čačić added the comment: However, this is an instance of a general problem: whenever we want to strongly type (via dunders) protocols that specialcase builtin types, we will have to choose between three options: * special case them also in typing engine, complicating the typing engine

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-30 Thread Batuhan
Batuhan added the comment: $ ./python -m pyperf timeit -s "from math import floor" --duplicate 100 "floor(12345.6)" Before: Mean +- std dev: 52.5 ns +- 2.6 ns After: Mean +- std dev: 71.0 ns +- 1.7 ns $ ./python -m pyperf timeit -s "from math import ceil" --duplicate 100 "ceil(12345.6)"

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Mark Dickinson
Mark Dickinson added the comment: > If float.__ceil__ will be executed it will add significant overhead for > creating and executing the method object. Yes, I'd definitely like to see timings; I think Victor already asked for those on the PR. --

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Oh, you are right. I misunderstood the original issue and thought that the code first checks PyFloat_Check() or PyFloat_CheckExact(). If float.__ceil__ will be executed it will add significant overhead for creating and executing the method object.

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Mark Dickinson
Mark Dickinson added the comment: > I have doubts about adding a C code which is never even executed. My reading of the PR is that it *would* be executed: the math module first looks for the __floor__ special method, then falls back to using the libm floor if that doesn't exist. Am I

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If float.__ceil__ is only needed for typeshed, maybe add a special case for typeshed? I have doubts about adding a C code which is never even executed. -- nosy: +serhiy.storchaka ___ Python tracker

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Batuhan
Change by Batuhan : -- keywords: +patch pull_requests: +16511 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16985 ___ Python tracker ___

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Ran Benita
Ran Benita added the comment: You can take it - thanks! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Batuhan
Batuhan added the comment: Ran, do you want to work on this or can i take it? -- nosy: +BTaskaya ___ Python tracker ___ ___

[issue38629] float is missing __ceil__() and __floor__(), required by numbers.Real

2019-10-29 Thread Ran Benita
New submission from Ran Benita : The numbers.Real ABC requires the __ceil__ and __floor__ methods (https://github.com/python/cpython/blob/v3.8.0/Lib/numbers.py#L178-L186), however, the float type does not have them. In regular Python, this is not a problem, because math.ceil() and