Comparison to infinity when checking if a point is above a line
It would be faster to use the math.isinf() function:

&gt;&gt;&gt; from math import e, pi, isinf
&gt;&gt;&gt; s = [0, float('inf'), e, pi]
&gt;&gt;&gt; map(isinf, s)
[False, True, False, False]


The reason your current check is taking so long is due to how much work it has to do:

&gt;&gt;&gt; from dis import dis

&gt;&gt;&gt; def my_isinf(f):
        return f == float('Inf')

&gt;&gt;&gt; dis(my_isinf)
  2           0 LOAD_FAST                0 (f)
              3 LOAD_GLOBAL              0 (float)
              6 LOAD_CONST               1 ('Inf')
              9 CALL_FUNCTION            1
             12 COMPARE_OP               2 (==)
             15 RETURN_VALUE 


There is a global load which involves a dictionary lookup.  There is a two-arguments function call.  The Float constructor has to parse the string and then allocate (and refcount) a new float object in memory.  Then the comparison step dispatches its work to float.__eq__ which returns a boolean value which is then the fed to the if-statement.