Nov-07-2022, 04:59 AM
From the thread about getting random sets of image names we had 24 image names:
images = ['im1', 'im2', 'im3', 'im4', 'im5', 'im6', 'im7', 'im8',
'im9', 'im10', 'im11', 'im12', 'im13', 'im14', 'im15',
'im16', 'im17', 'im18','im19','im20','im21','im22','im23','im24']
Something funny is going on with itertools:
If I do this:
There are n!/(n-r)! permutations for any given n and r.
Set n = 24, r = 9, we have 24!/15! = 474 467 051 520 permutations.
Has my computer really created nearly 500 trillion 9-string tuples in milliseconds? Seems unlikely!
I don't know what goes on behind the scenes in Python, I believe a lot of modules are written in C, but that still seems extremely fast!
My laptop is fast with 2 Ryzen R7 processors, but that beggars belief!
Has it really made 500 trillion tuples? Has itertools created a generator and nothing else??
images = ['im1', 'im2', 'im3', 'im4', 'im5', 'im6', 'im7', 'im8',
'im9', 'im10', 'im11', 'im12', 'im13', 'im14', 'im15',
'im16', 'im17', 'im18','im19','im20','im21','im22','im23','im24']
Something funny is going on with itertools:
If I do this:
perm_set = itertools.permutations(images,9)This completes in the time it takes to press and release the enter key.
There are n!/(n-r)! permutations for any given n and r.
Set n = 24, r = 9, we have 24!/15! = 474 467 051 520 permutations.
Has my computer really created nearly 500 trillion 9-string tuples in milliseconds? Seems unlikely!
I don't know what goes on behind the scenes in Python, I believe a lot of modules are written in C, but that still seems extremely fast!
My laptop is fast with 2 Ryzen R7 processors, but that beggars belief!
Has it really made 500 trillion tuples? Has itertools created a generator and nothing else??