#11779: python ints vs sage ints with respect to powers weirdness
------------------------+---------------------------------------------------
Reporter: dimpase | Owner: AlexGhitza
Type: defect | Status: needs_review
Priority: major | Milestone: sage-4.7.2
Component: coercion | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author: Dmitrii Pasechnik
Merged: | Dependencies:
------------------------+---------------------------------------------------
Comment(by dimpase):
Replying to [comment:16 leif]:
> Replying to [comment:15 dimpase]:
> > Leif here gives arguments based on algebraic properties, so it should
be, for algebraic consistency that he cares about so much, that
{{{int(3)^-3==int(1)/int(3)^3}}}, but this is
> > not the case now, as Python 2 will convert 1/27 to 0.
>
> What makes you think I meant Python's broken `/` operator on `int`s? As
I said on sage-devel, the behaviour of that operator on `int`s is useless
since there's explicit truncating integer division already, namely `//`.
>
> > I advocate the rule that a binary operation involving a Sage integer
and a Python int should always produce a Sage type, as this is the case
with all the other binary operations.
>
> The notion of "binary operations" has no meaning in this context, as the
desired behaviour w.r.t. result types should depend on the definition of
the function, especially its commonly used signature, not its arity.
well, being an algebraist by training and active in this research area for
over 20 years, I tend to think that I know how to distinguish a binary
operation from something else. And in my (not so in this case) humble
opinion I think that exponentiation is a binary operation in this case.
>
> For exponentiation, the ''type'' of the exponent is irrelevant, only its
''value'' matters to deduce the type of the result of the operation, just
like for shift operations (which of course aren't commutative either).
>
> Or would you say `type( value << shift )` should depend on the type of
`shift`?
it can, potentially; e.g. when shifting is not understood in a narrow
context of binary words.
>
> This might perhaps look "consistent" from a syntactical point of view,
but simply isn't sound, i.e. doesn't make any sense in the semantic
domain.
Look, I know an opinion on this issue of a lot of unhappy beginning users
of Sage (the undergrads I currently teach), and they
are dazed and confused by this inconsistency, among others. And I am
merely trying to make Sage easier to use for them on this ticket.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11779#comment:17>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.