def test_fakepkg():
    assert func2() == 2
    assert func3() == 3
Example #2
0
def main():
    print("\n********************\n")
    func1()
    print("\n********************\n")
    func2()
    print("\n********************\n")
Example #3
0
def func3() -> str:
    """ Function returning the submodule name `sub_module`. """
    return __package__


if __name__ == "__main__":
    result1 = timeit("go_fast(x)", setup="from __main__ import x, go_fast")
    result2 = timeit("go_slow(x)", setup="from __main__ import x, go_slow")
    result3 = timeit("np_sum(y)", globals=globals(), number=100)
    result4 = timeit("sum_parallel(y)", globals=globals(), number=100)
    result5 = timeit("sum_parallel_fast(y)", globals=globals(), number=100)

    go_slow(x)
    if DEBUG:
        p = Stats("go_slow.cprofile")
        p.strip_dirs().sort_stats("tottime").print_stats()

    print("fast result: ", result1)
    print("slow result: ", result2)
    print("np sum result: ", result3)
    print("parallel sum result: ", result4)
    print("fast parallel sum result: ", result5)

    x, y = 1.0, 2.0
    print(add(x, y))

    print(mod2.func2())

    func3()
Example #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""#52 in chapter7

How to avoide cyclic reference
"""

# module1 -> module2 -> module3, module4, module5
# module3.func3() -> module1.func1()

from module1 import func1
from module2 import func2
from module3 import func3
from module4 import func4

func1()
func2()
func3()
func4()
Example #5
0
def test_func2():
    assert mod2.func2() == "This is a random return string"