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.
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: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 | |