
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2015-12-29 12:49 byskrah, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| 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)*![]() | Date: 2015-12-29 12:49 | |
Here's a fix for the fallout from#25928. I've set it torelease blocker to make sure we don't forget. | |||
| msg257184 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | 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)*![]() | Date: 2015-12-29 13:46 | |
No, I haven't done any benchmarks. In a quick test type(x) == floatdoes not seem any faster than isinstance(x, float), so perhaps wecould reduce the try/except complexity. | |||
| msg257190 -(view) | Author: Stefan Krah (skrah)*![]() | 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 theygo through additional try/excepts anyway. | |||
| msg257210 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | 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)*![]() | 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)*![]() | Date: 2016-05-06 12:02 | |
statistics_as_integer_ratio.diff has been committed in7b2fafd78c1d. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:25 | admin | set | nosy: +ned.deily github: 70162 |
| 2016-05-06 12:02:09 | berker.peksag | set | status: open -> closed nosy: +berker.peksag messages: +msg264968 resolution: fixed stage: commit review -> resolved |
| 2016-04-03 11:59:59 | skrah | set | messages: +msg262826 |
| 2015-12-29 19:32:46 | serhiy.storchaka | set | messages: +msg257210 |
| 2015-12-29 14:30:03 | skrah | set | messages: +msg257190 |
| 2015-12-29 13:46:59 | skrah | set | messages: +msg257186 |
| 2015-12-29 13:29:04 | serhiy.storchaka | set | messages: +msg257184 stage: commit review |
| 2015-12-29 12:49:31 | skrah | create | |