Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Very Large Arrays

by salva (Abbot)
on Feb 17, 2012 at 16:41 UTC ( #954563=note: print w/ replies, xml ) Need Help??

in reply to Very Large Arrays

Shuffling an array is one of those thinks that can be done much more efficiently in C/XS than in Perl.

I have just uploaded to CPAN Array::Shuffle, that is one or two orders of magnitude faster than List::Util::shuffle or your hand-crafted shuffle implementation in Perl.

It's memory usage is O(1).

(List::Util::shuffle is also implemented in C, but it has the wrong interface from a performance point of view)

Comment on Re: Very Large Arrays
Replies are listed 'Best First'.
Re^2: Very Large Arrays
by Anonymous Monk on Feb 17, 2012 at 17:02 UTC
    As List::Util is available separately on CPAN, why didn't you submit a patch to that, so everybody benefits?
      Because Array::Shuffle functions do the operations in-place for better performance and so they do not really fit inside List::Util, and also because List::Util is famous for refusing to include additional functions (that's why we also have List::MoreUtil).

      Besides that, because I also wanted to play with different shuffle algorithms, and so creating a new specialiced module made sense to me.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://954563]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2015-12-01 09:53 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (798 votes), past polls