<commit_before>my class Pair does Associative {
    has $.key is default(Nil);
    has $.value is rw is default(Nil);

    multi method new(Mu \key, Mu \value) {
        my \p := nqp::create(self);
        nqp::bindattr(p, Pair, '$!key', nqp::decont(key));
        nqp::bindattr(p, Pair, '$!value', value);
        p
    }
    multi method new(Mu :$key, Mu :$value) {
        my \p := nqp::create(self);
        nqp::bindattr(p, Pair, '$!key', $key);
        nqp::bindattr(p, Pair, '$!value', $value);
        p
    }

    multi method ACCEPTS(Pair:D: %h) {
        $.value.ACCEPTS(%h{$.key});
    }

    multi method ACCEPTS(Pair:D: Mu $other) {
        $other."$.key"().Bool === $.value.Bool
    }

    method antipair(Pair:D:) { self.new(key => $!value, value => $!key) }
    method freeze(Pair:D:) { $!value := nqp::decont($!value) }

    multi method keys(Pair:D:)      { ($!key,).list }
    multi method kv(Pair:D:)        { $!key, $!value }
    multi method values(Pair:D:)    { ($!value,).list }
    multi method pairs(Pair:D:)     { (self,).list }
    multi method antipairs(Pair:D:) { self.new(key => $!value, value => $!key) }<commit_msg>Make smartmatching with a Pair a bit faster<commit_after>my class Pair does Associative {
    has $.key is default(Nil);
    has $.value is rw is default(Nil);

    multi method new(Mu \key, Mu \value) {
        my \p := nqp::create(self);
        nqp::bindattr(p, Pair, '$!key', nqp::decont(key));
        nqp::bindattr(p, Pair, '$!value', value);
        p
    }
    multi method new(Mu :$key, Mu :$value) {
        my \p := nqp::create(self);
        nqp::bindattr(p, Pair, '$!key', $key);
        nqp::bindattr(p, Pair, '$!value', $value);
        p
    }

    multi method ACCEPTS(Pair:D: %h) {
        $!value.ACCEPTS(%h.AT-KEY($!key));
    }
    multi method ACCEPTS(Pair:D: Pair:D $p) {
        $!value.ACCEPTS(nqp::getattr($p,Pair,'$!value'));
    }
    multi method ACCEPTS(Pair:D: Mu $other) {
        $other."$!key"().Bool === $!value.Bool
    }

    method antipair(Pair:D:) { self.new(key => $!value, value => $!key) }
    method freeze(Pair:D:) { $!value := nqp::decont($!value) }

    multi method keys(Pair:D:)      { ($!key,).list }
    multi method kv(Pair:D:)        { $!key, $!value }
    multi method values(Pair:D:)    { ($!value,).list }
    multi method pairs(Pair:D:)     { (self,).list }
    multi method antipairs(Pair:D:) { self.new(key => $!value, value => $!key) }
{'fraction_non_alphanumeric': 0.20499181669394434, 'fraction_numerical': 0.0, 'mean_word_length': 2.671171171171171, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5584311', 'n_tokens_mistral': 928, 'n_tokens_neox': 892, 'n_words': 207}