Changes between Version 2 and Version 12 of Ticket #24247


Ignore:
Timestamp:
11/22/17 08:12:31 (4 years ago)
Author:
jdemeyer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24247

    • Property Commit changed from to 0d3aa638f654dbc104ec85887eedfdb13e271589
    • Property Dependencies changed from #24244 to #24248, #24259, #24260
    • Property Branch changed from to u/jdemeyer/implement___pow___in_the_coercion_model
  • Ticket #24247 – Description

    v2 v12  
    11`__pow__` is harder than most other arithmetic coercions because you sometimes want the exponent to be an integer and sometimes you want full coercion.
    22
    3 To solve this, we first check whether the exponent is "integer-like". If so, we call `_pow_int`. If not, we do the usual coercion.
     3To solve this, we essentially do as follows:
     4
     51. If the arguments have equal parents, call `_pow_`.
     6
     72. If the exponent is "integer-like", call `_pow_int`.
     8
     93. If none of the above applies, do the usual coercion to a common parent. That will call `_pow_` unless the coerced arguments have a custom implementation of `__pow__`.
     10
     11Furthermore, the 3-argument version of `pow()` is not supported in the coercion model. Only specific types like `Integer` implement it.
    412
    513This is related to Python 3 (see #16072) because this check for an integer needs to be changed in light of the changes to the `int`/`long` types.