diff 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
line wrap: on
line diff
--- a/python/pydc/examples/sintest.py	Sun Jan 12 12:10:38 2020 +0100
+++ b/python/pydc/examples/sintest.py	Tue Apr 07 21:16:37 2020 +0200
@@ -15,28 +15,32 @@
 else:
   libm = pydc.load("/lib/libm.so.6")
 
-fpsin = pydc.find(libm,"sin")
+fp_sin = pydc.find(libm,"sin")
 
 
 
 def f1(n):
-  for x in xrange(n):
+  x = 0
+  while x < n:
     math.sin(x)
+    x += 1
 #  filter( math.sin, range(0,n) )
 
-def libmsin(x): pass
+#def libmsin(x): pass
 
 def f2(n):
-  for x in xrange(n):
-    pydc.call(fpsin,"d)d",float(x))
+  x = 0
+  while x < n:
+    pydc.call(fp_sin,"d)d",float(x))
+    x += 1
 #    libmsin(i)
 
 #  filter( libmsin , range(0,n) )
 
 
-print "start_native"+str(os.times())
+print("start_native "+str(os.times()))
 f1(10000000)
-print "start_dc"+str(os.times())
+print("start_dc "+str(os.times()))
 f2(10000000)
-print "end"+str(os.times())
+print("end "+str(os.times()))