Gayathri J wrote: > Dear Peter > > Below is the code I tried to check if itertools.product() was faster than > normal nested loops... > > they arent! arent they supposed to be...
I wouldn't have expected product() to be significantly faster, but neither did I expect it to be slower. > or am i making a mistake? any > idea? For your testcase you can shave off a small amount by avoiding the tuple- unpacking for t in product(...): f[t] = 0.0 but that may be cheating, and the effect isn't big. When you are working with numpy there may be specialised approaches, but f[:,:,:] = 0.0 is definitely cheating I suppose... -- https://mail.python.org/mailman/listinfo/python-list