""" nFromAddress.py """ import numpy import time, sys def fromaddress(address, dtype, shape, strides=None): """ Create a numpy array from an integer address, a dtype or dtype string, a shape tuple, and possibly strides. """ # Make sure our dtype is a dtype, not just "f" or whatever. dtype = numpy.dtype(dtype) class Dummy(object): pass d = Dummy() d.__array_interface__ = dict( data = (address, False), typestr = dtype.str, descr = dtype.descr, shape = shape, strides = strides, version = 3, ) return numpy.asarray(d) nAddress = sys.argv[1] print 'recvd addr', nAddress a3 = fromaddress(nAddress, numpy.int16, (4,)) ## any of the following cause a Python/Windows error on access print a3 #a3[0] = 5