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.

classification
Title: Fix statistics.py after the Decimal.as_integer_ratio() change
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steven.daprano Nosy List: belopolsky, berker.peksag, johnwalker, mark.dickinson, ned.deily, python-dev, rhettinger, serhiy.storchaka, skrah, steven.daprano, terry.reedy
Priority: release blocker Keywords: 3.5regression, patch

Created on 2015-12-29 12:49 by skrah, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
statistics_as_integer_ratio.diff skrah, 2015-12-29 12:49 review
Messages (7)
msg257178 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2015-12-29 12:49
Here's a fix for the fallout from #25928.  I've set it to
release blocker to make sure we don't forget.
msg257184 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-29 13:29
LGTM.

I haven't tested that "type(x) is float or type(x) is Decimal" is faster than alternatives ("type(x) in (float, Decimal)", or "isinstance(x, (float, Decimal))", or "hasattr(x, 'as_integer_ratio')") and believe you have tested this.
msg257186 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2015-12-29 13:46
No, I haven't done any benchmarks. In a quick test type(x) == float
does not seem any faster than isinstance(x, float), so perhaps we
could reduce the try/except complexity.
msg257190 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2015-12-29 14:30
The clear winner for float and Decimal is hasattr(x, 'as_integer_ratio').
The other types are a bit disadvantaged if the lookup fails, but they
go through additional try/excepts anyway.
msg257210 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-29 19:32
I believe the current code is well-weighed compromise that optimize different cases ranged for their frequency of occurrence (floats, ints, decimals, fractions, subclasses of int, float, etc and independed numeric types). And new addition unlikely will change the balance too much, but we have to be aware. If Steven have no something to add, the patch LGTM.
msg262826 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2016-04-03 11:59
Ping. Just a reminder that it would be nice to get this into 3.6-alpha-1. :)
msg264968 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-05-06 12:02
statistics_as_integer_ratio.diff has been committed in 7b2fafd78c1d.
History
Date User Action Args
2022-04-11 14:58:25adminsetnosy: + ned.deily
github: 70162
2016-05-06 12:02:09berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg264968

resolution: fixed
stage: commit review -> resolved
2016-04-03 11:59:59skrahsetmessages: + msg262826
2015-12-29 19:32:46serhiy.storchakasetmessages: + msg257210
2015-12-29 14:30:03skrahsetmessages: + msg257190
2015-12-29 13:46:59skrahsetmessages: + msg257186
2015-12-29 13:29:04serhiy.storchakasetmessages: + msg257184
stage: commit review
2015-12-29 12:49:31skrahcreate