import Extest print(Extest.abs(-2)) print(Extest.reverse('abc')) Extest.test()
import Extest Extest.test() print(Extest.fac(5)) print(Extest.reverse('hello'))
#!/usr/bin/env python # -*- coding: utf-8 -*- import Extest Extest.add(1, 2) Extest.fac(5) Extest.sum((1, 2, 3), 3) Extest.reverse('abcdefg') Extest.test()
import sys import os sys.path.append(os.getcwd() + "/build/lib.win-amd64-3.6/") import Extest import time from ctypes import * import os # extest = cdll.LoadLibrary("E:\py_mix_c2\\build\\temp.win-amd64-3.6\Release\Extest.cp36-win_amd64.lib") start = time.time() a = Extest.reverse("abcd") timeC = time.time() - start print('C costs', timeC, 'the result is', a) start = time.time() b = list("abcd") b.reverse() b = ''.join(b) timePython = time.time() - start print('Python costs', timePython, 'the result is', b)