in reply to Re^2: Making perl's map and grep more large list friendly
in thread Making perl's map and grep more large list friendly
I would seem foolish to me to pour a significant volume of time rooting around in a perl's monstrous code base finding the bits to patch, patching them, only then to be told "no, no, we cant do that because of this".
You could announce your intentions to the committers on the p5p mailing list or on their IRC channel.
no closer to tacking down where map and grep are implemented. Anyone know off the top of their shaved heads?.
$ perl -MO=Concise -e'grep { f() } $x..$y;' c <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v:{ ->3 8 <|> grepwhile(other->9)[t7] vK ->c 7 <@> grepstart K* ->8 3 <0> pushmark s ->4 - <1> null lK/1 ->4 - <1> null sK/1 ->8 - <@> scope sK ->8 - <0> ex-nextstate v ->9 b <1> entersub[t2] sKS/TARG,1 ->- - <1> ex-list sK ->b 9 <0> pushmark s ->a - <1> ex-rv2cv sK ->- a <#> gv[*f] s/EARLYCV ->b - <1> null lKM/1 ->7 6 <1> flop lKM ->7 e <1> flip[t6] lK ->7 4 <|> range(other->5)[t5] lK/1 ->d - <1> ex-rv2sv sK/1 ->e d <#> gvsv[*x] s ->e - <1> ex-rv2sv sK/1 ->6 5 <#> gvsv[*y] s ->6 -e syntax OK
So pp_grepstart and pp_grepwhile (in pp*.c) for grep. Similarly, map is pp_mapstart and pp_mapwhile.
Keep in mind that the list is already flattened before grep and map see it. First, you'd need to create new ops or use the "S"tacked flag like Perl does for for. (It doesn't appear to be used by the relevant ops.)
$ perl -MO=Concise -e'1 for $x..$y;' ... 8 <{> enteriter(next->9 last->c redo->9) lKS/8 ->a ... ^ | Stacked: Is a counting loop $ perl -MO=Concise -e'1 for (),$x..$y;' ... 9 <{> enteriter(next->a last->d redo->a) lK/8 ->b ... ^ | Not Stacked: Is a foreach loop
Then, you'd need to alter the compiler to produce the right opcode tree when a range is provided.
Update: s/Special/Stacked/
|
|---|