#19597: General code cleanup: avoid code like x.__eq__(y)
-------------------------------------+-------------------------------------
Reporter: jdemeyer | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.10
Component: misc | Resolution:
Keywords: | Merged in:
Authors: Jeroen Demeyer | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/jdemeyer/general_code_cleanup__avoid_x___eq___y_|
b2094a8a1cedafab73db0ed7653db3112982cec4
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by vdelecroix):
Could you comment more on this two changes
{{{#!diff
diff --git a/src/sage/coding/codecan/codecan.pyx
b/src/sage/coding/codecan/codecan.pyx
index 4d092d1..7b0bec3 100644
--- a/src/sage/coding/codecan/codecan.pyx
+++ b/src/sage/coding/codecan/codecan.pyx
@@ -803,7 +803,6 @@ cdef class
PartitionRefinementLinearCode(PartitionRefinement_generic):
self._hyp_refine_vals_scratch = <long *> sage_malloc(
self._hyp_part.degree * sizeof(long))
if self._hyp_refine_vals_scratch is NULL:
- self.__dealloc__()
raise MemoryError('allocating PartitionRefinementLinearCode')
self._hyp_refine_vals = _BestValStore(self._hyp_part.degree)
}}}
{{{#!diff
diff --git a/src/sage/combinat/crystals/tensor_product.py
b/src/sage/combinat/crystals/tensor_product.py
index 9596832..f3d277b 100644
--- a/src/sage/combinat/crystals/tensor_product.py
+++ b/src/sage/combinat/crystals/tensor_product.py
@@ -163,7 +163,7 @@ class ImmutableListWithParent(CombinatorialElement):
sage: m != n
True
"""
- return not self.__eq__(other)
+ return not self == other
def __lt__(self, other):
"""
@@ -199,9 +199,7 @@ class ImmutableListWithParent(CombinatorialElement):
sage: m <= n
True
"""
- if self == other:
- return True
- return self.__lt__(other)
+ return self == other or self.__lt__(other)
def __gt__(self, other):
@@ -237,9 +235,7 @@ class ImmutableListWithParent(CombinatorialElement):
sage: m >= n
False
"""
- if self == other:
- return True
- return self.__gt__(other)
+ return self == other or self.__gt__(other)
def sibling(self, l):
}}}
More comments:
`combinat/root_system/weyl_characters.py`: a very strange way to compute
powers `self * self ** (n-1)`. I guess that generic power would be better
here!
`groups/perm_gps/permgroup.py`: Is there any difference between `list(L)`
and `[x for x in L]`? As far as I understand `list` is smarter and call
for `__len__` to allocate directly the right amount of memory. Whereas the
second uses `.append`.
--
Ticket URL: <http://trac.sagemath.org/ticket/19597#comment:9>
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.
For more options, visit https://groups.google.com/d/optout.