示例#1
0
def method_speed(n=3000000):
    from timeit import Timer
    from pysrc.optimize.optimize_constants import make_constants
    # import builtins

    method = Timer(self.bar).timeit

    self.foo = make_constants(self=self)(foo)
    const = Timer(self.foo).timeit

    method_total = const_total = 0

    from itertools import count
    i = 1
    try:
        for i in count(1):

            aresult = const(n)
            bresult = method(n)

            method_total += bresult
            const_total += aresult

            print()
            print("method:", bresult, "const:", aresult)
            print("method Total", method_total / i, "const Total:", const_total / i)
            print()
    except KeyboardInterrupt:
        return method_total / i, const_total / i
示例#2
0
join = '\\'.join


def dirwalk(dir):
    contents = listdir(dir)
    paths = []; path_append = paths.append
    for f in contents:
        path = join((dir, f))
        try:
            paths.extend(dirwalk(path))
        except OSError:
            path_append(path)
    return paths

# noinspection PyUnresolvedReferences
dirwalk = make_constants(listdir=listdir, OSError=OSError, join=join)(dirwalk)


def get_xl_data2():

    from officelib.xllib.xlcom import xlBook2
    from officelib.const import xlDown
    from pysrc.snippets import smooth1
    import re
    from itertools import takewhile
    xl, wb = xlBook2('PID.xlsx')
    ws = wb.Worksheets('p30')
    cells = ws.Cells

    # columns = (5, 9, 13, 17, 21, 25, 29)
    columns = range(2, 19, 4)