【发布时间】:2014-06-11 09:44:33
【问题描述】:
我正在用 Python (https://gist.github.com/Synthetica9/73def2ec09d6ac491c98) 编写一些 J 绑定。但是,我在处理任意精度整数时遇到了一个问题:输出没有任何意义。每次都是不同的(但总体上是相同的)。相关代码:
def JTypes(desc, master):
newdesc = [item.contents.value for item in desc]
type = newdesc[0]
if debug: print type
rank = newdesc[1]
shape = ct.c_int.from_address(newdesc[2]).value
adress = newdesc[3]
#string
if type == 2:
charlist = (ct.c_char.from_address(adress+i) for i in range(shape))
return "".join((i.value for i in charlist))
#integer
if type == 4:
return ct.c_int.from_address(adress).value
#arb-price int
if type == 64:
return ct.c_int.from_address(adress).value
和
class J(object):
def __init__(self):
self.JDll = ct.cdll.LoadLibrary(os.path.join(jDir, "j.dll"))
self.JProc = self.JDll.JInit()
def __call__(self, code):
#Exec code, I suppose.
self.JDll.JDo(self.JProc, "tmp=:"+code)
return JTypes(self.deepvar("tmp"),self)
我们将不胜感激。
【问题讨论】:
标签: python data-structures j