🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
rbt Profile after: rbt.ca/profile-1584662492.294586.html#/routines 00:02
Changes: github.com/cosimo/perl6-string-crc...f86c82a576
Still not exactly wonderful. cksum is about 500 times faster.
MasterDuke rbt: changing to loop() was faster for you? 00:03
rbt Yeah, reliably by a few seconds. 00:04
MasterDuke huh. how are you testing?
rbt use String::CRC32;
my $filename = '/home/rbt/Downloads/testfiles/IMG_20180818_200909.jpg';
my $body = $filename.IO.slurp(:bin);
my $start-time = now;
my $crc = String::CRC32::crc32($body);
say "DURATION: ", now - $start-time;
say "CRC: ", $crc;
Pulling .elems out was important, otherwise it was called every cycle. 00:05
MasterDuke rbt: how does this path compare for you? gist.github.com/MasterDuke17/89b12...2d6856f927 00:18
*patch 00:19
rbt MasterDuke: Running. 00:21
My Version: 00:22
DURATION: 8.5288935
DURATION: 8.90089845
DURATION: 8.38934993
Your version:
DURATION: 20.6358398
DURATION: 20.6340732
DURATION: 21.3765229
This is Rakudo version 2020.01 built on MoarVM version 2020.01.1
implementing Perl 6.d.
MasterDuke huh. your version is slower for me 00:24
rbt Neat. 00:25
MasterDuke This is Rakudo version 2020.02.1-207-g9429728cb built on MoarVM version 2020.02.1-47-g3c3ad0678
rbt Running rakudobrew for 2020.02.1. I'll give it a go in a bit. 00:27
MasterDuke rbt: also, you could try making @CRC_TABLE an int array in your version, should help some more 00:37
rbt Like this? 00:40
-my @CRC_TABLE =
+my int @CRC_TABLE =
This is Rakudo version 2020.02.1 built on MoarVM version 2020.02.1 00:41
Original: 23.77407696 23.4043312 23.1602506
MasterDuke patch: 20.3623889 19.8017556 20.1483947
My Patch: 8.03932501 7.7126718 7.76500124
MasterDuke huh
rbt Mine + Int table: 9.0697465 10.605331 9.2615094
Linux rbt-inspiron-123 5.3.0-40-generic #32-Ubuntu SMP Fri Jan 31 20:24:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
MasterDuke i don't really understand those differences in results 00:42
rbt Perhaps I stumbled on some kind of memory layout thing that improves throughput for my specific setup.
rbt Or, would Blob work differently due to being from a file instead of a string? 00:43
MasterDuke i don't think so... 00:44
can you try with what i was doing? `String::CRC32::crc32("abcdefghijklmnopqrstuvwxyz0123456789~!#^_+;:./>?" x 100_000)`
rbt TEST: time r -e 'use String::CRC32; say String::CRC32::crc32("abcdefghijklmnopqrstuvwxyz0123456789~!#^_+;:./>?" x 100_000)' 00:49
Original: 0m15.660s 0m15.752s
MasterDuke Patch: 0m12.312s 0m12.106s
My Patch: 0m7.111s 0m7.099s
My Patch + Int table: 0m8.444s 0m8.741s
Thought I would try out your test just to rule out something with Blob.
MasterDuke and i just tried your patch again and it still isn't much faster for me. i guess some weird hardware/compiler/os difference 00:52
rbt For my actual use I ended up with run 'cksum', :out, :in and the timings are closer to 20 milliseconds for my sample file. 00:57
MasterDuke could you try another small change (to your version), `my int $char = $b.read-int8($i)` instead of `$b[$i]`? 01:02
rbt Not really a measurable difference. 01:06
MasterDuke oh well 01:07
MasterDuke timotimo: any idea why MVM_frame_find_lexical_by_name and MVM_multi_cache_find_callsite_args would be the 2nd and 3rd most expensive functions for that String::CRC32 code? 01:23
MasterDuke oh, but that's only for the loop() version 01:25
pilne So I've recently gotten infatuated with "how" prolog works(logic/declarative paradigm), I'm a hobby coder, is there somewhere to start with raku to utilize it as a solver, or if it isn't something in existance yet, would a module or a inline::prolog kinda thing be lower-hanging fruit for doing 01:29
logic/declarative kinda stuff in raku?
AlexDaniel pilne: I don't think Raku currently offers anything similar 01:56
pilne: some features can perhaps give you the same feeling but are nowhere close to what prolog offers 01:57
AlexDaniel btw I'm still not sure how this works: 01:58
m: say <aa foo a b bar rrr baz x y z> ~~ (**, ‘foo’, **, ‘bar’, **, ‘baz’, **)
camelia True
pilne fair! and thank you, seeing as prolog can be implimented in javascript, i'm.... sure that with grammers/macros it could be implimented in raku? 02:00
pilne i'm sure i could always look at metacpan.org/pod/AI::Prolog as well for inspiration! 02:01
(or cheat and use that with inline::perl5 :D )
jdv79 m: class A { has Str:D @.b; }; my %h = :b(1,2,3); A.new: |%h 05:49
camelia Type check failed in assignment to @!b; expected Str:D but got List ($(1, 2, 3))
in block <unit> at <tmp> line 1
jdv79 how does one do that then?
SmokeMachine m: class A { has Str:D @.b; }; my %h = :b(Array[Str:D].new: 1,2,3); A.new: |%h 07:51
camelia Type check failed in assignment to ; expected Str:D but got Int (1)
in block <unit> at <tmp> line 1
SmokeMachine m: class A { has Str:D @.b; }; my %h = :b(Array[Str:D].new: “1”,”2”,”3”); A.new: |%h 07:53
camelia Type check failed in assignment to @!b; expected Str:D but got Array[Str:D] (Array[Str:D].new("1", "2", "3"))
in block <unit> at <tmp> line 1
SmokeMachine m: class A { has Str @.b; }; my %h = :b(Array[Str].new: “1”,”2”,”3”); A.new: |%h 07:54
camelia Type check failed in assignment to @!b; expected Str but got Array[Str] (Array[Str].new("1", "2", "3"))
in block <unit> at <tmp> line 1
SmokeMachine m: my Str @b = Array[Str].new: “1”,”2”,”3”; say @b 07:57
camelia [1 2 3]
Kaiepi m: say Map.new: gather { take foo => 1 } 11:39
camelia Unexpected named argument 'foo' passed
in block <unit> at <tmp> line 1
Kaiepi m: say Map.new: gather { take (foo => 1) }
camelia Map.new((foo => 1))
Kaiepi oh 11:40
m: say Map.new: gather { take 'foo', 1 }
camelia Map.new((foo => 1))
Kaiepi m: my % is Map = gather { take 'foo', 1 }
camelia Odd number of elements found where hash initializer expected:
Only saw: $("foo", 1)
in block <unit> at <tmp> line 1
Kaiepi m: say my % is Map = gather { take 'foo', 1 }
camelia Odd number of elements found where hash initializer expected:
Only saw: $("foo", 1)
in block <unit> at <tmp> line 1
Kaiepi m: say my % is Map = gather { take (foo => 1) } 11:41
camelia Map.new((foo => 1))
Kaiepi weird
lizmat m: take :foo 11:43
camelia Unexpected named argument 'foo' passed
in block <unit> at <tmp> line 1
lizmat m: my %h = (1,2) 11:44
camelia ( no output )
lizmat m: my %h = $(1,2)
camelia ( no output )
lizmat m: my %h = $(1,2); dd %h
camelia Hash %h = {"1" => 2}
lizmat hmmm
m: my %h = ((1,2))
camelia ( no output )
lizmat I guess single arg rule at play
Kaiepi m: use nqp; nqp::p6bindattrinvres(nqp::create(List), List, '$!reified', nqp::list(1)).VAR.^name.say 11:47
camelia List
lizmat you told it to create one... 11:48
Kaiepi ik, i thought p6bindattrinvres did something or other with containers
Kaiepi m: class Foo does Associative { method new(|args) { say 'new: ', args; self.bless }; method STORE(|args) { say 'STORE: ', args; self } }; my %foo is Foo = :1a; %foo = :2b; 15:11
camelia new: \()
STORE: \(:a(1), :INITIALIZE)
STORE: \(:b(2))
Kaiepi m: class Foo does Associative { method new(|args) { say 'new: ', args; self.bless }; method STORE(|args) { say 'STORE: ', args; self } }; my %foo is Foo = :1a; %foo = :2b :DECONT;
camelia new: \()
STORE: \(:a(1), :INITIALIZE)
STORE: \(:b(2))
Kaiepi when do the :DECONT variations of STORE get called? 15:12
or is it just an internal thing
bronco_creek Hello raku folks. I have a few lines of code that demonstrate a raku behavior that I don't understand. Is there a way to paste them here so that they will be evaluated? Someone here might be able to explain to me what's happening. 16:36
AlexDaniel bronco_creek: try gist.github.com/
bronco_creek Thanks AlexDaniel. I will do that. 16:37
bronco_creek I'd appreciate it if someone could have a look at my short gist at gist.github.com/bronco-creek/dbd1b...35737c389d When I assign variables to values in a hash, they work as expected. When I push hashes into an array, it seems like the variables are bound rather than assigned. 17:05
Altai-man_ bronco_creek, your %coords hash is not copied to an array, so when you change values in the hash, when you refer to it from the array it is changed as well. 17:13
or, hmmmm 17:16
never mind that. :S
tobs m: my $x = 10; my %h = 'x', $x; say %h; $x = 12; say %h 17:18
camelia {x => 10}
{x => 10}
tobs so the 'x' key definitely gets its own container in the hash
m: my $x = 10; my %h = 'x', $x; my @space; say %h; @space.push(%h); $x = 12; %h = 'x', $x; say %h; @space.push(%h); say @space 17:20
camelia {x => 10}
{x => 12}
[{x => 12} {x => 12}]
tobs m: my $x = 10; my %h = 'x', $x; my @space; @space.push(%h); $x = 12; %h = 'x', $x; @space.push(%h); say @space[0].WHICH eq @space[1].WHICH 17:20
camelia True
sena_kun bisectable6, my @space; my %coords = 'x', 1234, 'y', 1234; @space.push(%coords); say @space[0]; my %coords = 'x', 42, 'y', 42; @space.push(%coords); .say for @space; 17:21
bisectable6 sena_kun, Bisecting by output (old=2015.12 new=509a7f6) because on both starting points the exit code is 0
sena_kun, bisect log: gist.github.com/a0172cc2339b72985c...b13f871580
sena_kun, (2016-04-05) github.com/rakudo/rakudo/commit/6a...822dac090b
tobs sena_kun: bogus result :/ 17:22
bisectable6: my $x = 10; my %h = 'x', $x; my @space; @space.push(%h); $x = 12; %h = 'x', $x; @space.push(%h); say @space[0].WHICH eq @space[1].WHICH
bisectable6 tobs, On both starting points (old=2015.12 new=509a7f6) the exit code is 0 and the output is identical as well
tobs, Output on both points: «True␤»
sena_kun even if you declare a new %coords, it's still the same
bronco_creek I hope someone can summarize if/when they understand this. I'm afraid I have no experience with the bisect tool you are using. 17:25
Kaiepi m: my $foo = 1; my @foo = {:$foo}; say @foo; $foo = 2; say @foo 17:37
camelia [foo => 1]
[foo => 1]
Kaiepi m: my $foo = 1; my @foo; @foo.push: {:$foo}; say @foo; $foo = 2; say @foo
camelia [{foo => 1}]
[{foo => 1}]
Kaiepi m: my $foo = 1; my @foo; @foo.push: {foo => $foo}; say @foo; $foo = 2; say @foo 17:38
camelia [{foo => 1}]
[{foo => 1}]
Kaiepi m: my $foo = 1; my @foo; @foo.push: my % = :$foo; say @foo; $foo = 2; say @foo
camelia [{foo => 1}]
[{foo => 1}]
Kaiepi m: my $foo = 1; my @foo; @foo.push: my % = :$foo; say @foo; $foo = 2; @foo.push: my % = :$foo; say @foo
camelia [{foo => 1}]
[{foo => 1} {foo => 2}]
17:39
Kaiepi m: my $foo = 1; my @foo; @foo.push: my % = 'foo', $foo; say @foo; $foo = 2; @foo.push: my % = 'foo', $foo; say @foo 17:39
camelia [{foo => 1}]
[{foo => 1} {foo => 2}]
Kaiepi ohh wait i think i see what's going on 17:40
thundergnat The problem is you are pushing the containers onto the array, not the values
m: my %h = :10x; say %h; my @a; @a.push: %h; say @a; %h<x> = 5; @a.push: %h; say @a;
camelia {x => 10}
[{x => 10}]
[{x => 5} {x => 5}]
thundergnat contrast with
m: my %h = :10x; say %h; my @a; @a.push: %h.deepmap: *.clone; say @a; %h<x> = 5; @a.push: %h.deepmap: *.clone; say @a; 17:41
camelia {x => 10}
[{x => 10}]
[{x => 10} {x => 5}]
Kaiepi yeah, i missed that the hash was being reused
one way you can fix it is to change the second assignment to %coords to a bind instead 17:42
thundergnat Or do a deep clone like I showed above
bronco_creek Thanks tobs, sena_kun, Kaiepi, thundergnat. I need to study your examples more. 17:48
bronco_creek Deep clone is a new concept to me, but looks workable in the context where I hit this problem. I'm mapping one (large but finite )space to another, so I need to populate the mapping iteratively. 17:59
bronco_creek Thanks again, thundergnat. 18:00
timotimo MasterDuke: could try breakpointing the functions and seeing what kinds of strings it's asking for
tobs m: my $x = 10; my %h = 'x', $x; my @space; @space.push(%h<>); $x = 12; %h = 'x', $x; @space.push(%h<>); say @space 18:16
camelia [{x => 12} {x => 12}]
jnthn m: my $x = 10; my %h = 'x', $x; my @space; @space.push({%h}); $x = 12; %h = 'x', $x; @space.push({%h}); say @space 18:21
camelia [{x => 10} {x => 12}]
jnthn That's probably the most compact way to get the copy into a new hash
sena_kun jnthn, why it doesn't work when you declare a new hash? 18:23
I mean...
m: my @space; my %coords = 'x', 1234, 'y', 1234; @space.push(%coords); say @space[0]; my %coords = 'x', 42, 'y', 42; @space.push(%coords); .say for @space;
camelia Potential difficulties:
Redeclaration of symbol '%coords'
at <tmp>:1
------> 3push(%coords); say @space[0]; my %coords7⏏5 = 'x', 42, 'y', 42; @space.push(%coords
{x => 1234, y => 1234}
{x => 42, y => 42}
{x => 42, y => 42…
sena_kun you decalre %coords twice, it should be different, no?
jnthn The point of the redeclaration warning is that you're not declaring something new. 18:27
sena_kun m: my $a; my $a; 18:28
camelia Potential difficulties:
Redeclaration of symbol '$a'
at <tmp>:1
------> 3my $a; my $a7⏏5;
jnthn There's only one $a there. Same with the hash.
sena_kun *sounds of world crashing*
bronco_creek Thanks jnthn. I'm counting on learning Raku to keep me socially isolated ;-) Nice to see a supportive community here. 18:32
timotimo MFW you try to socially isolate yourself by learning a seemingly excentric programming language, and make some of the best friends. oops! 18:34
jast damn, that's rough 18:35
hope you bounced back from that
timotimo i may never recover 18:36
bronco_creek I'm fine, BTW. Just old, vulnerable and cautious. I did some work in perl6 several years ago. The community still looks like the great place i remember. 18:39
colomon I’ve run into something confusing with multi sub MAIN. example code: gist.github.com/colomon/148775fd20...b56f185d29 18:40
If I invoke the program with just one file argument, the split version is called — even though the I-thought-mandatory split argument isn’t set? 18:41
[Coke] colomon: :$split! ? 18:43
colomon [Coke]++ # that’s it!
dunno why I was forgetting that
MasterDuke timotimo: good thinking. 4.8 million calls each looking for `&postfix:<++>` and `&infix:«<»` 18:50
pilne i love the community around raku, it's my "relaxing/grounding" kinda space despite the fact i'm constantly poking around at other languages 18:59
like, i'm stupidly fascinated by prolog/logtalk/mercury/mini kanren stuff right now.
and i'm happier than a swine in slops that there's a perl prolog interpreter on cpan that looks like a great place for me to start looking into bringing something useful over to raku, while also satisfying my quirky likes! 19:00
uzl[m] So how do I set an environment variable for a module? I'm talking specifically about this (github.com/perl6/Pod-To-HTML#debugging). 19:11
moritz you don't set them for a module, but for a process 19:15
P6DOC_DEBUG=1 perl6 yourscript
P6DOC_DEBUG=1 perl6 --doc=html file.pod 19:16
uzl[m] moritz: I was trying with `P6DOC_DEBUG perl6 yourscript` ;-). Thanks! 19:18
wildtrees for getting DBIish to work with postgres, do I need some c libraries or something? any idea what they would be called on ubuntu? 19:24
Altai-man_ wildtrees, postgresql-dev I think 19:25
name of the package, I mean
oops, maybe `libpq-dev` 19:26
wildtrees Altai-man_, I did: sudo apt-get install postgresql-server-dev-all and it worked 19:39
Geth doc/any-minmax-by: f3af1a04f8 | (Stoned Elipot)++ | doc/Type/Any.pod6
Explicitly mention min/max/minmax()'s :by argument
20:41
doc: stoned++ created pull request #3269:
Explicitly mention min/max/minmax()'s :by argument
20:42
MasterDuke timotimo: it doesn't seem to happen if i just put a loop() in a 21:36
oops. '-e' was the end there
uzl[m] .seen jmerelo 22:07
tellable6 uzl[m], I saw jmerelo 2020-02-26T20:04:44Z in #raku-dev: <jmerelo> tbrowder: that would be OK, I think.
uzl[m] .tell jmerelo: Could you take a look at this "feature" branch (github.com/uzluisf/Pod-To-HTML/tre...r-changes) for Pod::To::HTML? BTW, is there any reason why the `pod2html` and `node2*` subroutines are exported? 22:13
tellable6 uzl[m], I'll pass your message to jmerelo
timotimo MasterDuke: huh, but those aren't dynamic variables? 23:14
MasterDuke correct, they are not 23:15
timotimo well, that's a little odd.
you could try calling MVM_dump_bytecode(tc) when stopped at one of these
MasterDuke btw, i'm in the middle of creating a new rakudo issue about it. have you seen my recent experimentation in #whateverable? 23:16
timotimo i have not 23:19
MasterDuke committable6: 9658dd9~2,9658dd9~1,9658dd9 class FOO { our proto sub foo($) {*}; multi sub foo(Int $n) { my @a = ^$n; my $b; loop (my $i = 0; $i < $n; $i++) { $b = @a[$i] }; return $b }; multi sub foo(Str $s) { return foo($s.Int) } }; say FOO::foo(1_000_000); say now - INIT now 23:20
committable6 MasterDuke, ¦9658dd9~2: «999999␤1.3731685␤» ¦9658dd9~1: «Cannot test this commit (Commit exists, but an executable could not be built for it)» ¦9658dd9: «999999␤2.3190604␤»
kybr how do i look up the :2years syntax used in this example: say Date.new('2015-12-24').later(:2years); 23:21
timotimo interesting
kybr: that's "colon pair syntax"
kybr thanks! 23:21
timotimo MasterDuke: that commit is the one from july 2017? 23:22
MasterDuke yep
timotimo well, that looks like a big change in moar 23:23
MasterDuke yeah, i'm kind of surprised it wasn't noticed before 23:29
timotimo we should revert moar, nqp, and rakudo to 2017 and start over
MasterDuke timotimo: gist.github.com/MasterDuke17/ece19...26da661c75 23:31
timotimo oh wait that's getlexstatic 23:32
... why the heck did i think it was looking up dynamic variables
i think i derped that on reading 23:33
normally spesh would be able to turn those lookups into wval instructions
oh, there's still speshresolve calls there, so this is an unspeshed frame
can you let it run a few thousand times and look again?
i mean let the loop run, so spesh can collect the data and optimize that frame? 23:34
MasterDuke that loop had been running for a whle 23:35
i have a 7.9gb log file with 167279995 lines of bytecode. pretty sure what i gisted was from the end of the file
MasterDuke timotimo: i added: `char *n = MVM_string_utf8_encode_C_string(tc, name); if (strcmp(n, "&postfix:<++>") == 0) { fprintf(stderr, "found %s\n", n); MVM_dump_bytecode(tc); }` to the top of MVM_frame_find_lexical_by_name 23:37
Geth doc: tinmarino++ created pull request #3270:
Object: Inheritance: Add parent direct call with $obj.Parent::method
23:49
timotimo oh dan 23:53
dang
timotimo and the code is even already inside a function of its own 23:54
MasterDuke ?