prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  optimizing `transform_geom` for repeated transformations
  Related to: https://github.com/Toblerity/Fiona/issues/799
  
  Is there interest in adding this to rasterio as well?
  
  </issue>
  <code>
  [start of rasterio/compat.py]
  1 """Python 2-3 compatibility."""
  2 
  3 import itertools
  4 import sys
  5 import warnings
  6 
  7 
  8 if sys.version_info[0] >= 3:   # pragma: no cover
  9     string_types = str,
  10     text_type = str
  11     integer_types = int,
  12     zip_longest = itertools.zip_longest
  13     import configparser
  14     from urllib.parse import urlparse
  15     from collections import UserDict
  16     from collections.abc import Iterable, Mapping
  17     from inspect import getfullargspec as getargspec
  18 else:  # pragma: no cover
  19     warnings.warn("Python 2 compatibility will be removed after version 1.1", DeprecationWarning)
  20     string_types = basestring,
  21     text_type = unicode
  22     integer_types = int, long
  23     zip_longest = itertools.izip_longest
  24     import ConfigParser as configparser
  25     from urlparse import urlparse
  26     from UserDict import UserDict
  27     from inspect import getargspec
  28     from collections import Iterable, Mapping
  29
  [end of rasterio/compat.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/rasterio/compat.py b/rasterio/compat.py
  --- a/rasterio/compat.py
  +++ b/rasterio/compat.py
  @@ -26,3 +26,8 @@
       from UserDict import UserDict
       from inspect import getargspec
       from collections import Iterable, Mapping
  +
  +# Users can pass in objects that subclass a few different objects
  +# More specifically, rasterio has a CRS() class that subclasses UserDict()
  +# In Python 2 UserDict() is in its own module and does not subclass Mapping()
  +DICT_TYPES = (dict, Mapping, UserDict)
  
verification_info: {"golden_diff": "diff --git a/rasterio/compat.py b/rasterio/compat.py\n--- a/rasterio/compat.py\n+++ b/rasterio/compat.py\n@@ -26,3 +26,8 @@\n     from UserDict import UserDict\n     from inspect import getargspec\n     from collections import Iterable, Mapping\n+\n+# Users can pass in objects that subclass a few different objects\n+# More specifically, rasterio has a CRS() class that subclasses UserDict()\n+# In Python 2 UserDict() is in its own module and does not subclass Mapping()\n+DICT_TYPES = (dict, Mapping, UserDict)\n", "issue": "optimizing `transform_geom` for repeated transformations\nRelated to: https://github.com/Toblerity/Fiona/issues/799\r\n\r\nIs there interest in adding this to rasterio as well?\n", "before_files": [{"content": "\"\"\"Python 2-3 compatibility.\"\"\"\n\nimport itertools\nimport sys\nimport warnings\n\n\nif sys.version_info[0] >= 3:   # pragma: no cover\n    string_types = str,\n    text_type = str\n    integer_types = int,\n    zip_longest = itertools.zip_longest\n    import configparser\n    from urllib.parse import urlparse\n    from collections import UserDict\n    from collections.abc import Iterable, Mapping\n    from inspect import getfullargspec as getargspec\nelse:  # pragma: no cover\n    warnings.warn(\"Python 2 compatibility will be removed after version 1.1\", DeprecationWarning)\n    string_types = basestring,\n    text_type = unicode\n    integer_types = int, long\n    zip_longest = itertools.izip_longest\n    import ConfigParser as configparser\n    from urlparse import urlparse\n    from UserDict import UserDict\n    from inspect import getargspec\n    from collections import Iterable, Mapping\n", "path": "rasterio/compat.py"}]}