Speeding up permutations generation

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Fri Mar 6 03:44:39 EST 2015


On 03/06/2015 09:34 AM, Mark Lawrence wrote:
> On 06/03/2015 06:44, Abhiram R wrote:
>> Hi all,
>> Is there a way to generate permutations of large arrays of sizes say,in
>> the hundreds, faster than in the time itertools.permutations() can
>> return?
>>
>> ​-Abhiram.R
>> /~Never give up/
>>
>
> If there is I'd guess that you'd use numpy http://www.numpy.org/.  The
> more mathematically minded may well be able to give better answers.
>

Well, numpy would be faster if you could call into it once and retrieve 
all permutations as an array. This would allow you to do all 
calculations in C, while itertools.permutations has to jump back and 
forth between C and Pyhon code.

However, 50! is still ~ 3*10^64. So where would you want to store the 
array of these many permutations ?




More information about the Python-list mailing list