[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > chachi: > > I want to know how to instantiate a data structure which has n bytes > > (given by me) and is internally stored in a contiguous fashion. > > array.array("B", ...) may be fit for you. You can also use a numpy > array of bytes.
The mmap module is useful also for larger amounts (>4k say). mmap's are individually free-able so they don't fragment your memory. http://docs.python.org/library/mmap.html Eg create a 1 GB anonymous mmap, access it and then delete it >>> from mmap import mmap >>> a = mmap(-1, 1000000000) >>> a[0] '\x00' >>> a[0] = 'z' >>> a[999999999] '\x00' >>> a[999999999]='q' >>> a[999999999] 'q' >>> del a -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list