Inline::Perl5 now supports passing IO (including deep and dark IO from within XS), so this code works:
use v6; use Slang::Tuxic; use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.use ("Text::CSV_XS"); my @rows; my $csv = $p5.invoke ("Text::CSV_XS", "new") or die "Cannot use CSV: ", $p5.invoke ("Text::CSV_XS", "error_diag +"); $csv.binary (1); $csv.auto_diag (1); my $fh = open "/tmp/hello.csv", :r, chomp => False; my Int $sum = 0; while (my $r = $csv.getline ($fh)) { $sum += +$r; } $sum.say;
To give an example of performance (seconds needed to parse 10000 lines of 5 fields each). Note that Text::CSV::Easy_* only accepts valid CSV and has no options.
Perl 5 | |
| Text::CSV::Easy_XS | 0.019 |
| Text::CSV::Easy_PP | 0.017 |
| Text::CSV_XS with bind_columns | 0.033 |
| Text::CSV_XS | 0.038 |
| Text::CSV_PP | 0.517 |
| Pegex::CSV | 1.350 |
Perl 6 | |
| State machine (no options yet) | 7.027 |
| Inline::Perl5 + Text::CSV_XS | 13.082 |
| Inline::Perl5 + Text::CSV_XS + getline (IO) | 13.142 |
| Inline::Perl5 + Text::CSV_PP | 13.623 |
| Grammar-based (no options yet) | 13.210 |
| Regex based (no options) | 39.996 |
| Regex based, all options provided | 36.075 |
When I started in october 2014, the Regex based solution took 260 seconds, so improvement in the language itself is made on a daily basis!
In reply to Re: Perl 5, Python, Rakudo, C/C++, Java, Lua?
by Tux
in thread Perl 5, Python, Rakudo, C/C++, Java, Lua?
by raiph
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |