#12116: perfect_power for integers
----------------------------------------------------------------+-----------
Reporter: roed |
Owner: AlexGhitza
Type: enhancement |
Status: needs_work
Priority: major |
Milestone: sage-5.8
Component: basic arithmetic |
Resolution:
Keywords: | Work
issues:
Report Upstream: Fixed upstream, but not in a stable release. |
Reviewers: David Loeffler
Authors: David Roe | Merged
in:
Dependencies: #10596, #12363, #12638 |
Stopgaps:
----------------------------------------------------------------+-----------
Changes (by roed):
* status: needs_review => needs_work
Comment:
> * `cdef int exp = 1` in the second hunk - since
> {{{
> sage: type(4.perfect_power()[0])
> sage.rings.integer.Integer
> }}}
> and you now reassign `exp` to that, does that line make any sense at
all? It's certainly not an int.
I think Cython is smart enough to figure out what's going on here since
Integer has an `__int__` method. You can see in the generated C code for
`exp, b = b.perfect_power()` (leaving out lots of error checking and
reference counting):
{{{
__pyx_t_1 = PyObject_GetAttr(__pyx_v_b, __pyx_n_s__perfect_power);
__pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple),
NULL);
PyObject* sequence = __pyx_t_7;
Py_ssize_t size = Py_SIZE(sequence);
__pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_1);
__pyx_v_exp = __pyx_t_11;
}}}
> * Do we need to deprecate `base_exponent`? It would be easy enough,
basically same code as deprecating `is_power` except reverse the order of
the output.
It's probably a good idea. I'll do it shortly.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12116#comment:23>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.