Implement timeit() in extended class in python
<p>Naive programmer: I'm trying to use the timeit module but I don't know how. I have extended the class:</p>

<pre><code>class Pt:
   def __init__(self, x,y):
        self.x = x
        self.y = y
class pt_set(Pt):
    def __init__(self):
        self.pts = []
    def distance(self):
        ...
        ...
     return d,(pt1,pt2)
</code></pre>

<p>And I have made an object:</p>

<pre><code>new_points = Pt_set()
</code></pre>

<p>then calling distance:</p>

<pre><code>new_points.distance()
</code></pre>

<p>How can I use the timeit() function on the distance() function?</p>

<p>It is all explained in the <a href="https://docs.python.org/2/library/timeit.html" rel="nofollow">docs</a>, and this is an example taken from there:</p>

<pre><code> def test():
    """Stupid test function"""
    L = []
    for i in range(100):
        L.append(i)

if __name__ == '__main__':
    import timeit
    print(timeit.timeit("test()", setup="from __main__ import test"))
</code></pre>

<p>for complete ref please read the docs.</p>

python ipython timeit