#25225: Unnecessary/Redundant __iter__ method with ListMixin class
(contrib.gis.geos.mutable_list.py)?
-------------------------------------+-------------------------------------
     Reporter:  bixb0012             |      Owner:  nobody
         Type:                       |     Status:  new
  Cleanup/optimization               |
    Component:  GIS                  |    Version:  1.8
     Severity:  Normal               |   Keywords:  __iter__ geos gis
                                     |  ListMixin
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  1                    |      UI/UX:  0
-------------------------------------+-------------------------------------
 The ListMixin class (contrib.gis.geos.mutable_list.py) currently has an
 __iter__ method and __getitem__ method.  Typically iteration is
 implemented using one or the other, not both.  Looking at the two methods,
 the __iter__ method appears to be unnecessary since the Python interpreter
 will use __getitem__ to iterate if __iter__ is not present.  Also,
 stepping through code appears to have __iter__ call __getitem__, which
 raises the question of why define an __iter__ method when the interpreter
 can use __getitem__ directly.

 Currently, __getitem__ can't be used properly for iteration because of the
 custom IndexError raised in the _checkindex method.  Switching from
 raising a django.contrib.gis.geos.error.GEOSIndexError exception to a
 exceptions.IndexError will allow for the interpreter to use __getitem__
 for iteration, which would allow removing the unnecessary or redundant
 __iter__ method.

--
Ticket URL: <https://code.djangoproject.com/ticket/25225>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.86803a63e6cc108670eede8984de59da%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to