perl - array of integers using way too much memory?

后端 未结 8 859
我寻月下人不归
我寻月下人不归 2021-01-18 06:05

When I run the following script:

my @arr = [1..5000000];

for($i=0; $i<5000000; $i++) {
        $arr[$i] = $i;
        if($i % 1000000 == 0) {
                    


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-18 06:37

    If you are dealing with such large arrays, you might want to use a toolkit like the PDL.

    (Oh, and yes, you are correct: It takes so much memory because it is an array of Perl scalars.)

提交回复
热议问题