Changes between Initial Version and Version 1 of Ticket #25225


Ignore:
Timestamp:
Aug 4, 2015, 2:27:40 PM (9 years ago)
Author:
Tim Graham
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25225 – Description

    initial v1  
    1 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.
     1The `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.
    22
    3 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.
    4 
     3Currently, `__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.
Back to Top