<commit_before>from _blist import blist
from ctypes import c_int
import collections
class btuple(collections.Sequence):
    __slots__ = ['_hash', '_blist']
    def __init__(self, seq=None):
        if isinstance(seq, btuple):
            self._blist = seq._blist
        elif seq is not None:
            self._blist = blist(seq)
        else:
            self._blist = blist()
        self._hash = -1

    def _btuple_or_tuple(self, other, f):
        if isinstance(other, btuple):
            rv = f(self._blist, other._blist)
        elif isinstance(other, tuple):
            rv = f(self._blist, blist(other))
        else:
            return NotImplemented
        if isinstance(rv, blist):
            rv = btuple(rv)
        return rv        
        
    def __hash__(self):
        # Based on tuplehash from tupleobject.c
        if self._hash != -1:
            return self._hash
        
        n = len(self)
        mult = c_int(1000003)
        x = c_int(0x345678)
        for ob in self:
            n -= 1
            y = c_int(hash(ob))
            x = (x ^ y) * mult
            mult += c_int(82520) + n + n
        x += c_int(97531)
        if x == -1:
            x = -2;
        self._hash = x.value
        return self._hash

    def __add__(self, other):
        rv = self._btuple_or_tuple(other, blist.__add__)
        if rv is NotImplemented:
            raise TypeError
        return rv        
    def __contains__(self, item):
        return item in self._blist<commit_msg>Added btuple support for __radd__<commit_after>from _blist import blist
from ctypes import c_int
import collections
class btuple(collections.Sequence):
    __slots__ = ['_hash', '_blist']
    def __init__(self, seq=None):
        if isinstance(seq, btuple):
            self._blist = seq._blist
        elif seq is not None:
            self._blist = blist(seq)
        else:
            self._blist = blist()
        self._hash = -1

    def _btuple_or_tuple(self, other, f):
        if isinstance(other, btuple):
            rv = f(self._blist, other._blist)
        elif isinstance(other, tuple):
            rv = f(self._blist, blist(other))
        else:
            return NotImplemented
        if isinstance(rv, blist):
            rv = btuple(rv)
        return rv        
        
    def __hash__(self):
        # Based on tuplehash from tupleobject.c
        if self._hash != -1:
            return self._hash
        
        n = len(self)
        mult = c_int(1000003)
        x = c_int(0x345678)
        for ob in self:
            n -= 1
            y = c_int(hash(ob))
            x = (x ^ y) * mult
            mult += c_int(82520) + n + n
        x += c_int(97531)
        if x == -1:
            x = -2;
        self._hash = x.value
        return self._hash

    def __add__(self, other):
        rv = self._btuple_or_tuple(other, blist.__add__)
        if rv is NotImplemented:
            raise TypeError
        return rv
    def __radd__(self, other):
        rv = self._btuple_or_tuple(other, blist.__radd__)
        if rv is NotImplemented:
            raise TypeError
        return rv
    def __contains__(self, item):
        return item in self._blist
{'fraction_non_alphanumeric': 0.0939070351758794, 'fraction_numerical': 0.01821608040201005, 'mean_word_length': 1.5936482084690553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4568352', 'n_tokens_mistral': 1012, 'n_tokens_neox': 977, 'n_words': 271}