Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2015-07-07 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls