代码高亮
admin
撰写于 2022年 10月 16 日

from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"

哈哈哈哈

代码高亮

from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"
from timeit import timeit
lst = [i for i in range(100)]
def good(num):
    return num >= 60
def with_for():
    ret = []
    for num in lst:
        if good(num):
            ret.append(num)
    return ret
def without_for():
    return [filter(good, lst)]
print(f"with:    {timeit(with_for, number=10000)}")
print(f"without:{timeit(without_for, number=10000)}"

哈哈哈哈


版权属于:admin 所有,采用《知识共享署名-相同方式共享许可协议》进行许可,转载请注明文章来源。

本文链接: https://b3.typecho.ru/index.php/default/37.html

上一篇
图片模式
下一篇
测试写书

猜您想看

  • ddsfdf

    fdddf

    2023年04月22日
  • 按钮

    5666ddd...

    2022年11月16日
  • gffg

    fggfg

    2023年06月06日
  • hhhhh

    FlowCha...

    2023年04月06日
  • ddddd

    sdsdsds...

    2023年06月11日

评论区(暂无评论)

这里空空如也,快来评论吧~

我要评论