Mercurial > pub > dyncall > bindings
view python/pydc/examples/sintest.py @ 46:c21d1c2c84e1
- removed pydc.py wrapper overhead (which only called pydcext.so functions, directly, anyways)
* implies renaming pydcext.* to pydc.*
* while at it, iterate directly over args that are passed in (before we did extract fptr, sig and a tuple for the args and iterated over latter afterwards); we might have a tiny perf improvement now
- added type stub as package_data
author | Tassilo Philipp |
---|---|
date | Fri, 13 Nov 2020 14:10:31 +0100 |
parents | edbbd467f50a |
children |
line wrap: on
line source
import math import os import pydc import sys import platform if sys.platform == "win32": libm = pydc.load("msvcrt") elif sys.platform == "darwin": libm = pydc.load("/usr/lib/libm.dylib") elif "bsd" in sys.platform: libm = pydc.load("/usr/lib/libm.so") elif platform.architecture()[0] == "64bit": libm = pydc.load("/lib64/libm.so.6") else: libm = pydc.load("/lib/libm.so.6") fp_sin = pydc.find(libm,"sin") def f1(n): x = 0 while x < n: math.sin(x) x += 1 # filter( math.sin, range(0,n) ) #def libmsin(x): pass def f2(n): 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())) f1(10000000) print("start_dc "+str(os.times())) f2(10000000) print("end "+str(os.times()))