etianen/django-optimizations — pull request #9 by danielsamuels (2014-09-03 14:12:21+00:00)
Title: Updates for Python 3 compatibility.

Apologies for the whitespace changes in the diff, you can see a version without them [here](https://github.com/onespacemedia/django-optimizations/commit/1e2f4897f7f892d2f9b6c2acb79987ba088258b8?w=0).

This pull request brings Python 3 compatibility into the library with the following changes:

* Change instances of `basestring` to `str`
* Change dict `iteritems` to `items`
* Import `urlparse` from `urllib.parse` instead of `urlparse`
* Wrap calls to `filter()` in a `list()` to allow `len()` to be called

There are a couple of caveats with this Pull Request, primarily that with the changes to `iteritems`, users using Python 2.x will no longer have an iterator when looping over the urls which could have a minor change in memory usage. I don't expect this to cause issues in real-world scenarios, but it's worth noting. In addition, with the changes to the `basestring` checks it means that byte strings will no longer be checked, this could be resolved by comparing against `(str, bytes)`.

I have not managed to perform any extensive testing with these changes, but I have tested locally using Python 2.7.7 and Python 3.4.1.