New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Int..Whatever ranges are slow (~20 times slower than Int..Int) #4303
Comments
From @hoelzroLet's say I have an array where @array.end == $end. Using @array[0..$end] is about 20 times faster than @array[0..*]. I have attached an example script that demonstrates this. |
From @lizmat
If it’s the whole array that you want, have you considered using the zen slice? That is still a lot faster than [0..$end]. Looking at why the * case is so slow. Liz |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznetOn Sat, 06 Jun 2015 20:24:32 -0700, rob@hoelz.ro wrote:
Thanks for the report, however there's no issue with the compiler here. You're comparing different behaviours: 0..* is a lazy Iterable, so extra checks <Zoffix__> m: my @array = 1..1000; my $end = @array.end; for ^500 { $ = @array[0..*] }; say now - INIT now |
@zoffixznet - Status changed from 'open' to 'rejected' |
From @AlexDanielSo-o. Zoffix insists that everything is correct here, and perhaps it is so. That being said, I don't quite understand why it can't be done. Maybe somebody else can take a look also. Here's my logic: So if you have @array[0..@array.end] and @array[0..*] Would we get identical results from both of these snippets? I guess we should. But if it is so, why can't it just pretend that * is @array.end? If I understand correctly, the range object is right there for inspection, so everything should be possible. Zoffix++ pointed out ( https://irclog.perlgeek.de/perl6/2017-10-08#i_15273200 ) that 0..* will stop at the first hole, but there's a ticket for that: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127573 So assuming that the bug is eventually resolved and both @array[0..@array.end] and @array[0..*] start giving exactly the same result in all cases, why can't it be done? And if these two snippets give different results, then what are these difference? This would be some good doc material. If there's a chance that it can be done, let's keep this open. The difference is dramatic and [0..*] is very common in normal code. On 2017-10-07 21:44:40, cpan@zoffix.com wrote:
|
@AlexDaniel - Status changed from 'rejected' to 'open' |
From @zoffixznetOn Sat, 07 Oct 2017 22:19:46 -0700, alex.jakimenko@gmail.com wrote:
Done now in rakudo/rakudo@456358e3c3 |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#125344 (status was 'resolved')
Searchable as RT125344$
The text was updated successfully, but these errors were encountered: