Opened 4 years ago
Last modified 4 years ago
#24247 closed enhancement
Implement __pow__ in the coercion model — at Version 12
Reported by:  jdemeyer  Owned by:  

Priority:  major  Milestone:  sage8.2 
Component:  coercion  Keywords:  
Cc:  Merged in:  
Authors:  Jeroen Demeyer  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  u/jdemeyer/implement___pow___in_the_coercion_model (Commits, GitHub, GitLab)  Commit:  0d3aa638f654dbc104ec85887eedfdb13e271589 
Dependencies:  #24248, #24259, #24260  Stopgaps: 
Description (last modified by )
__pow__
is harder than most other arithmetic coercions because you sometimes want the exponent to be an integer and sometimes you want full coercion.
To solve this, we essentially do as follows:
 If the arguments have equal parents, call
_pow_
.
 If the exponent is "integerlike", call
_pow_int
.
 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__
.
Furthermore, the 3argument version of pow()
is not supported in the coercion model. Only specific types like Integer
implement it.
This 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.
Change History (12)
comment:1 Changed 4 years ago by
 Description modified (diff)
comment:2 Changed 4 years ago by
 Description modified (diff)
comment:3 Changed 4 years ago by
 Dependencies changed from #24244 to #24248
comment:4 Changed 4 years ago by
 Branch set to u/jdemeyer/implement___pow___in_the_coercion_model
comment:5 Changed 4 years ago by
 Commit set to a18280f20d1a3a9d87300be699b5efa77ac10d8b
comment:6 Changed 4 years ago by
 Commit changed from a18280f20d1a3a9d87300be699b5efa77ac10d8b to 8b194fb82d37eb5036f36ee37cf6b38bc27e0d30
comment:7 Changed 4 years ago by
 Commit changed from 8b194fb82d37eb5036f36ee37cf6b38bc27e0d30 to 54eb896167c809daad138588f9bc86b5c5659591
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
54eb896  Implement __pow__ in the coercion model

comment:8 Changed 4 years ago by
 Dependencies changed from #24248 to #24248, #24259
comment:9 Changed 4 years ago by
 Commit changed from 54eb896167c809daad138588f9bc86b5c5659591 to 5e031351b06fe41b299b1f2fb74cb294f3489fb1
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
5e03135  Implement __pow__ in the coercion model

comment:10 Changed 4 years ago by
 Dependencies changed from #24248, #24259 to #24248, #24259, #24260
comment:11 Changed 4 years ago by
 Commit changed from 5e031351b06fe41b299b1f2fb74cb294f3489fb1 to 0d3aa638f654dbc104ec85887eedfdb13e271589
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
88eaed5  Declare Integer.value as array

5c1f43f  Deprecate str ^ Integer

70592a8  Fix compiler warning

d3db645  Merge commit '88eaed585d8159a4a0763e56caaf3a767d4cb2f0'; commit '5c1f43f861165ff975616f60cab37c92d36d10f6'; commit '70592a850d7677928592c022760d6183bd81364f' into t/24247/implement___pow___in_the_coercion_model

0d3aa63  Implement __pow__ in the coercion model

comment:12 Changed 4 years ago by
 Description modified (diff)
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
Fake Integer interface
New functions integer_check_long() and integer_check_long_py()
Fix isinstance(x, int) calls in element.pyx
Implement __pow__ in the coercion model