#19597: General code cleanup: avoid code like x.__eq__(y)
----------------------------------+-------------------------
       Reporter:  jdemeyer        |        Owner:
           Type:  enhancement     |       Status:  new
       Priority:  major           |    Milestone:  sage-6.10
      Component:  misc            |   Resolution:
       Keywords:                  |    Merged in:
        Authors:  Jeroen Demeyer  |    Reviewers:
Report Upstream:  N/A             |  Work issues:
         Branch:                  |       Commit:
   Dependencies:                  |     Stopgaps:
----------------------------------+-------------------------
Description changed by jdemeyer:

Old description:

> Replace code of the form
> {{{
> x.__eq__(y)
> x.__len__()
> x.__getitem__(y)
> x.__contains__(y)
> ...
> }}}
> by
> {{{
> x == y
> len(x)
> x[y]
> y in x
> ...
> }}}
> because the latter are more efficient.
>
> The obvious exceptions are `super()` calls and `Class.__method__(...)`
> calls.
>
> In a few cases, we reorganize the code to avoid special functions/methods
> altogether:
> 1. for `__repr__()`, we instead change `%s` to `%r` for `%`-formatting
> and `{}` to `{!r}` for `.format()`.
> 2. certain calls to `__iter__()` can be changed to a simple list
> comprehension.
> 3. there are subtle differences between `a.__eq__(b)` and `a == b` and in
> certain technical cases they do matter.

New description:

 Replace code of the form
 {{{
 x.__eq__(y)
 x.__len__()
 x.__getitem__(y)
 x.__contains__(y)
 ...
 }}}
 by
 {{{
 x == y
 len(x)
 x[y]
 y in x
 ...
 }}}
 because the latter are more efficient.

 The obvious exceptions are `super()` calls and `Class.__method__(...)`
 calls.

 In a few cases, we reorganize the code to avoid special functions/methods
 altogether:
 1. for `__repr__()`, we instead change `%s` to `%r` for `%`-formatting and
 `{}` to `{!r}` for `.format()`.
 2. certain calls to `__iter__()` can be changed to a simple list
 comprehension.
 3. there are subtle differences between `x.__eq__(y)` and `x == y` and in
 certain technical cases they do matter.

--

--
Ticket URL: <http://trac.sagemath.org/ticket/19597#comment:5>
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.

Reply via email to