<commit_before>#! /usr/bin/python3

import timeit


def list_comprehension(input):
    data = [element for element in elements]


def for_loop(input):
    data = []
    for element in elements:
        data.append(element)


def optimised_for_loop(input):
    data = []
    appender = data.append
    for element in elements:
        appender(element)


elements = list(range(100))

print("Elements: {0}".format(len(elements)))
print("For Loop: {0}".format(timeit.timeit("for_loop(elements)", setup="from __main__ import for_loop, elements ")))
print("Optimised For Loop: {0}".format(timeit.timeit("optimised_for_loop(elements)", setup="from __main__ import optimised_for_loop, elements ")))
print("List Comprehension: {0}".format(timeit.timeit("list_comprehension(elements)", setup="from __main__ import list_comprehension, elements")))<commit_msg>Returning data to be more like real-life code.<commit_after>#! /usr/bin/python3

import timeit


def list_comprehension(input):
    return [element for element in elements]


def for_loop(input):
    data = []
    for element in elements:
        data.append(element)

    return data


def optimised_for_loop(input):
    data = []
    appender = data.append
    for element in elements:
        appender(element)

    return data


elements = list(range(100))

print("Elements: {0}".format(len(elements)))
print("For Loop: {0}".format(timeit.timeit("for_loop(elements)", setup="from __main__ import for_loop, elements ")))
print("Optimised For Loop: {0}".format(timeit.timeit("optimised_for_loop(elements)", setup="from __main__ import optimised_for_loop, elements ")))
print("List Comprehension: {0}".format(timeit.timeit("list_comprehension(elements)", setup="from __main__ import list_comprehension, elements")))
{'fraction_non_alphanumeric': 0.13427762039660057, 'fraction_numerical': 0.009065155807365438, 'mean_word_length': 5.284697508896797, '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': '771676', 'n_tokens_mistral': 578, 'n_tokens_neox': 551, 'n_words': 128}