From 0dd81de56726f3250dc05d9c0ec8de8a942c5d53 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Wed, 31 Dec 2014 14:36:01 +1100 Subject: [PATCH] Add paragraph about data locality --- doc/source/user_guide/numpy_images.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/source/user_guide/numpy_images.txt b/doc/source/user_guide/numpy_images.txt index b2cdf3b4..a3a73bef 100644 --- a/doc/source/user_guide/numpy_images.txt +++ b/doc/source/user_guide/numpy_images.txt @@ -182,3 +182,11 @@ in a different order, even if the number of operations is the same: 1.18 seconds >>> print("Speedup: %.1fx" % ((s1 - s0) / (t1 - t0))) Speedup: 8.6x + + +When the dimension you are iterating over is even larger, the +speedup is even more dramatic. It is worth thinking about this +*data locality* when writing algorithms. In particular, know that +scikit-image uses C-contiguous arrays unless otherwise specified, so +one should iterate along the last/rightmost dimension in the +innermost loop of the computation.