Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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)

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]
[karlgoethebier]: good morning
[Corion]: Hi karlgoethebier!
[karlgoethebier]: anybody ever noticed the double bracket operator: while (<<>>) {print;}?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-07-21 07:49 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (319 votes). Check out past polls.