comparison python/pydc/examples/sintest.py @ 28:edbbd467f50a

python binding: - update to dyncall 1.1 - Python 3 support (supports both, Python 2 and 3) - using the Capsule API over PyCObject, when available - support for python unicode strings (for both, Python 2 and 3) - doc cleanup ruby binding: - doc cleanup
author Tassilo Philipp
date Tue, 07 Apr 2020 21:16:37 +0200
parents bf5625bb6f05
children
comparison
equal deleted inserted replaced
27:18e1f1bb1945 28:edbbd467f50a
13 elif platform.architecture()[0] == "64bit": 13 elif platform.architecture()[0] == "64bit":
14 libm = pydc.load("/lib64/libm.so.6") 14 libm = pydc.load("/lib64/libm.so.6")
15 else: 15 else:
16 libm = pydc.load("/lib/libm.so.6") 16 libm = pydc.load("/lib/libm.so.6")
17 17
18 fpsin = pydc.find(libm,"sin") 18 fp_sin = pydc.find(libm,"sin")
19 19
20 20
21 21
22 def f1(n): 22 def f1(n):
23 for x in xrange(n): 23 x = 0
24 while x < n:
24 math.sin(x) 25 math.sin(x)
26 x += 1
25 # filter( math.sin, range(0,n) ) 27 # filter( math.sin, range(0,n) )
26 28
27 def libmsin(x): pass 29 #def libmsin(x): pass
28 30
29 def f2(n): 31 def f2(n):
30 for x in xrange(n): 32 x = 0
31 pydc.call(fpsin,"d)d",float(x)) 33 while x < n:
34 pydc.call(fp_sin,"d)d",float(x))
35 x += 1
32 # libmsin(i) 36 # libmsin(i)
33 37
34 # filter( libmsin , range(0,n) ) 38 # filter( libmsin , range(0,n) )
35 39
36 40
37 print "start_native"+str(os.times()) 41 print("start_native "+str(os.times()))
38 f1(10000000) 42 f1(10000000)
39 print "start_dc"+str(os.times()) 43 print("start_dc "+str(os.times()))
40 f2(10000000) 44 f2(10000000)
41 print "end"+str(os.times()) 45 print("end "+str(os.times()))
42 46