in reply to Re^2: Fastest way to "pick without replacement"
in thread Fastest way to "pick without replacement"

My guess is that using a bit-string is the fastest approach.

Every set bit would represent a used number. °

Of course this would mean that the overall algorithm needs to be adjusted ...

Anyway in my experience you are doing micro-optimization here, the exponential growth of the search space makes better bound conditions to cut sub-trees far more important than tuning Perl.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

°) the strings can't get that big, a result set for 32 input numbers would already be beyond limits.

  • Comment on Re^3: Fastest way to "pick without replacement"

Replies are listed 'Best First'.
Re^4: Fastest way to "pick without replacement"
by haukex (Archbishop) on Nov 22, 2020 at 13:08 UTC
    Anyway in my experience you are doing micro-optimization here

    This was mostly to satisfy my curiosity and perhaps provide an interesting challenge, I'm not really optimizing anything - I always had a gut feeling that splice might be kind of slow (and it probably still is on very large arrays), so it's nice to see that in this test it's actually quite the opposite.

      Yes it's impressive how efficient splice is.

      Perl's array implementation is very clever in many ways, to approach the performance of linked lists, without loosing the benefits of O(1) random access to members.

      But I don't remember it being good at bridging holes....

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery