Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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]
[Corion]: Oh yay. The (external, not guided by me) programmers have chosen Moose+DBIx::Class for some implementation, and now seem to do 1+n SELECT statements for each row, as is usual when using ORMs.
[Corion]: So maybe I should investigate how to plug in a cache in front of DBIx::Class so I can do a ->selectall_hashre f and then satisfy the "sub"-selects from that cached single SELECT statement ...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-09-25 10:57 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (279 votes). Check out past polls.