access to preallocated block of memory?
Neil Hodgson
nyamatongwe+thunder at gmail.com
Thu Dec 15 16:47:20 EST 2005
Greg Copeland:
> I already have access to the block on memory...I
> simply need information about existing python facilities which will
> allow me to expose the block to python as a native type...from which I
> can read byte for byte and optionally write to. As I originally said,
> I have a pointer and the block's length. I have access to it already.
> I simply need to expose it to python. What facilities already exist to
> allow this which do not cause malloc/memcpy on said block?
There is no generic array.at(address,length) in core Python as it
would be a hole in Python's type system, allowing reading from or
writing to any memory location and thus making it easier for Python to
cause memory corruption and crashes. Libraries such as ctypes or its
predecessor calldll do allow such access on some operating systems but
not VxWorks. It would be quicker to write a special-purpose library for
your job rather than port ctypes.
Neil
More information about the Python-list
mailing list