A discussion arose in https://github.com/sympy/sympy/pull/518 which
involves modifications to divmod. The question that arose is whether
divmod should return Tuple(a, b) or (a, b). This is, in essence, a
question of where sympy should end and where python's underlying
structures should be left alone.
To start things off, I think that any function that is a duplicate of
a python function should return the same container but it should be
sure to return sympy objects in that container, so divmod(3, 2) -> (1,
1) while divmod(S(3), 2) -> (S(1), S(1)). Also, I think that standard
containers should be used unless they appear within an object. So cse
returns a list of lists, not a Tuple of Tuples. Returning a sympy
container draws attention to the container. It also will start to
raise confusion in interactive sessions where, for example, since
Tuple looks like tuple, it becomes visually unclear when the output
can or can't have a sympy method applied to it:
>>> Tuple(x, 2)
(x, 2)
>>> _.count_ops()
0
>>> (x, 2)
(x, 2)
>>> _.count_ops()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'count_ops'
Do you have some ideas or guiding principles for this issue?
--
You received this message because you are subscribed to the Google Groups
"sympy" 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/sympy?hl=en.