Python 2
print'Python', python_version()
print'\ntiming range()'
%timeit test_range(n)
print'\n\ntiming xrange()'
%timeit test_xrange(n)
Python2.7.6
timing range()
1000 loops, best of 3:433µs per loop
timing xrange()
1000 loops, best of 3:350µs per loop
Python 3
print('Python', python_version())
print('\ntiming range()')
%timeit test_range(n)
Python3.4.1
timing range()
1000 loops, best of 3:520µs per loop
print(xrange(10))
---------------------------------------------------------------------------
NameError Traceback(most recent call last)
<ipython-input-5-5d8f9b79ea70>in()
---->1print(xrange(10))
NameError: name 'xrange'isnotdefined