You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In almost every instance you use range, you should instead be using xrange. Test 16 is especially painful to look at as range(1000) already creates an array with the integers 0 to 999, which you then iterate over to create another copy of the array.
Test 16 should really be a comparison of the two versions you have (but using xrange instead of range), vs just "return range(1000)". A quick test on my system shows a simple "return range(1000)" to be a further 3-4x faster than your fastest Test 16 variant, and substituting xrange for range achieves a 20-30% improvement over your fastest variant.
The text was updated successfully, but these errors were encountered:
In almost every instance you use range, you should instead be using xrange. Test 16 is especially painful to look at as range(1000) already creates an array with the integers 0 to 999, which you then iterate over to create another copy of the array.
Test 16 should really be a comparison of the two versions you have (but using xrange instead of range), vs just "return range(1000)". A quick test on my system shows a simple "return range(1000)" to be a further 3-4x faster than your fastest Test 16 variant, and substituting xrange for range achieves a 20-30% improvement over your fastest variant.
The text was updated successfully, but these errors were encountered: