<commit_before>;(function($B){

var _b_ = $B.builtins,
    object = _b_.object,
    getattr = $B.$getattr,
    isinstance = _b_.isinstance,
    $N = _b_.None

function check_not_tuple(self, attr){
    if(self.__class__ === tuple){
        throw _b_.AttributeError.$factory(
            "'tuple' object has no attribute '" + attr +"'")
    }
}

function $list(){
    // used for list displays
    // different from list : $list(1) is valid (matches [1])
    // but list(1) is invalid (integer 1 is not iterable)
    return list.$factory.apply(null, arguments)
}

var list = {
    __class__: _b_.type,
    __mro__: [object],
    $infos: {
        __module__: "builtins",
        __name__: "list"
    },
    $is_class: true,
    $native: true,
    __dir__: object.__dir__
}

list.__add__ = function(self, other){
    if($B.get_class(self) !== $B.get_class(other)){
        var radd = getattr(other, "__radd__", _b_.NotImplemented)
        if(radd !== _b_.NotImplemented){return radd(self)}
        throw _b_.TypeError.$factory('can only concatenate list (not "' +
            $B.class_name(other) + '") to list')
    }
    var res = self.slice(),
        is_js = other.$brython_class == "js" // list of JS objects
    for(const item of other){
        res.push(is_js ? $B.$JS2Py(item) : item)
    }
    res.__brython__ = true
    if(isinstance(self, tuple)){res = tuple.$factory(res)}
    return res
}

list.__contains__ = function(self,item){
    var $ = $B.args("__contains__", 2, {self: null, item: null},
        ["self", "item"], arguments, {}, null, null),
        self = $.self,
        item = $.item
    var _eq = function(other){return $B.rich_comp("__eq__", item, other)}
    var i = 0
    while(i < self.length) {
        if(_eq(self[i])){return true}
        i++
    }
    return false
}

list.__delitem__ = function(self, arg){

    if(isinstance(arg, _b_.int)){
        var pos = arg
        if(arg < 0){pos = self.length + pos}
        if(pos >= 0 && pos < self.length){
            self.splice(pos, 1)
            return $N
        }
        throw _b_.IndexError.$factory("list index out of range")
    }
    if(isinstance(arg, _b_.slice)) {
        var step = arg.step
        if(step === $N){step = 1}
        var start = arg.start
        if(start === $N){start = step > 0 ? 0 : self.length}
        var stop = arg.stop
        if(stop === $N){stop = step > 0 ? self.length : 0}
        if(start < 0){start = self.length + start}
        if(stop < 0){stop = self.length + stop}
        var res = [],
            i = null,
            pos = 0
        if(step > 0){
            if(stop > start){
                for(var i = start; i < stop; i += step){
                    if(self[i] !== undefined){res[pos++] = i}
                }
            }
        }else{
            if(stop < start){
                for(var i = start; i > stop; i += step){
                    if(self[i] !== undefined){res[pos++] = i}
                }
                res.reverse() // must be in ascending order
            }
        }
        // delete items from left to right
        var i = res.length
        while(i--){
           self.splice(res[i], 1)
        }
        return $N
    }

    if(_b_.hasattr(arg, "__int__") || _b_.hasattr(arg, "__index__")){
       list.__delitem__(self, _b_.int.$factory(arg))
       return $N
    }

    throw _b_.TypeError.$factory("list indices must be integer, not " +
        _b_.str.$factory(arg.__class__))
}

list.__eq__ = function(self, other){
    if(isinstance(self, list)){var klass = list}else{var klass = tuple}
    if(isinstance(other, klass)){
       if(other.length == self.length){
            var i = self.length
            while(i--){
                if(! $B.rich_comp("__eq__", self[i], other[i])){return false}
            }
            return true
       }
    }
    return _b_.NotImplemented
}

list.__getitem__ = function(self, arg){
    var $ = $B.args("__getitem__",2,{self: null, key: null},
        ["self", "key"], arguments, {}, null, null),
        self = $.self,
        key = $.key<commit_msg>Small improvment of list slice operation<commit_after>;(function($B){

var _b_ = $B.builtins,
    object = _b_.object,
    getattr = $B.$getattr,
    isinstance = _b_.isinstance,
    $N = _b_.None

function check_not_tuple(self, attr){
    if(self.__class__ === tuple){
        throw _b_.AttributeError.$factory(
            "'tuple' object has no attribute '" + attr +"'")
    }
}

function $list(){
    // used for list displays
    // different from list : $list(1) is valid (matches [1])
    // but list(1) is invalid (integer 1 is not iterable)
    return list.$factory.apply(null, arguments)
}

var list = {
    __class__: _b_.type,
    __mro__: [object],
    $infos: {
        __module__: "builtins",
        __name__: "list"
    },
    $is_class: true,
    $native: true,
    __dir__: object.__dir__
}

list.__add__ = function(self, other){
    if($B.get_class(self) !== $B.get_class(other)){
        var radd = getattr(other, "__radd__", _b_.NotImplemented)
        if(radd !== _b_.NotImplemented){return radd(self)}
        throw _b_.TypeError.$factory('can only concatenate list (not "' +
            $B.class_name(other) + '") to list')
    }
    var res = self.slice(),
        is_js = other.$brython_class == "js" // list of JS objects
    for(const item of other){
        res.push(is_js ? $B.$JS2Py(item) : item)
    }
    res.__brython__ = true
    if(isinstance(self, tuple)){res = tuple.$factory(res)}
    return res
}

list.__contains__ = function(self,item){
    var $ = $B.args("__contains__", 2, {self: null, item: null},
        ["self", "item"], arguments, {}, null, null),
        self = $.self,
        item = $.item
    var _eq = function(other){return $B.rich_comp("__eq__", item, other)}
    var i = 0
    while(i < self.length) {
        if(_eq(self[i])){return true}
        i++
    }
    return false
}

list.__delitem__ = function(self, arg){

    if(isinstance(arg, _b_.int)){
        var pos = arg
        if(arg < 0){pos = self.length + pos}
        if(pos >= 0 && pos < self.length){
            self.splice(pos, 1)
            return $N
        }
        throw _b_.IndexError.$factory("list index out of range")
    }
    if(isinstance(arg, _b_.slice)) {
        var step = arg.step
        if(step === $N){step = 1}
        var start = arg.start
        if(start === $N){start = step > 0 ? 0 : self.length}
        var stop = arg.stop
        if(stop === $N){stop = step > 0 ? self.length : 0}
        if(start < 0){start = self.length + start}
        if(stop < 0){stop = self.length + stop}
        var res = [],
            i = null,
            pos = 0
        if(step > 0){
            if(stop > start){
                for(var i = start; i < stop; i += step){
                    if(self[i] !== undefined){res[pos++] = i}
                }
            }
        }else{
            if(stop < start){
                for(var i = start; i > stop; i += step){
                    if(self[i] !== undefined){res[pos++] = i}
                }
                res.reverse() // must be in ascending order
            }
        }
        // delete items from left to right
        var i = res.length
        while(i--){
           self.splice(res[i], 1)
        }
        return $N
    }

    if(_b_.hasattr(arg, "__int__") || _b_.hasattr(arg, "__index__")){
       list.__delitem__(self, _b_.int.$factory(arg))
       return $N
    }

    throw _b_.TypeError.$factory("list indices must be integer, not " +
        _b_.str.$factory(arg.__class__))
}

list.__eq__ = function(self, other){
    if(isinstance(self, list)){var klass = list}else{var klass = tuple}
    if(isinstance(other, klass)){
       if(other.length == self.length){
            var i = self.length
            while(i--){
                if(! $B.rich_comp("__eq__", self[i], other[i])){return false}
            }
            return true
       }
    }
    return _b_.NotImplemented
}

list.__getitem__ = function(self, key){
    // var $ = $B.args("__getitem__",2,{self: null, key: null},
    //     ["self", "key"], arguments, {}, null, null),
    //     self = $.self,
    //     key = $.key
    $B.check_no_kw("__getitem__", self, key)
    $B.check_nb_args("__getitem__", 2, arguments)
{'fraction_non_alphanumeric': 0.15774170099345772, 'fraction_numerical': 0.005209595347710201, 'mean_word_length': 1.9651580459770115, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '2085771', 'n_tokens_mistral': 2770, 'n_tokens_neox': 2720, 'n_words': 650}