We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rasterio/compat.py`
Content:
```
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 FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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)

{"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"}], "after_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\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()\nDICT_TYPES = (dict, Mapping, UserDict)\n", "path": "rasterio/compat.py"}]}