Nissl/Spatial_Pattern_Analysis — pull request #1 by bobbyi (2012-09-02 01:17:32+00:00)
Title: 25 - 30% speed increase by only calculating the sqrt if the distance is within bounds

The idea here is that we can compare the square of our distance (the value before we take the sqrt) to the square of our bounds (the lower of which is zero). If the value is not in bounds, then we don't have to take the sqrt. Avoiding the unnecessary sqrt operations gives a 25-30% speedup overall on my machine.

I also rewrote the bounds checking to use a chained comparison operator. In Python,

```python
if 0 < foo and foo < 32:
```
can be written as

```python
if 0 < foo < 32:
```