Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to use a contiguous memory location of n bytes in python

Reply
Thread Tools

How to use a contiguous memory location of n bytes in python

 
 
chachi
Guest
Posts: n/a
 
      11-14-2008
Hi,

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. I know
list is not implemented like this, so I am in a fix. There seems to be
a buffer object available, but haven't seen it being used anywhere.
Does anyone know how to use Buffer? Say I want to write some data onto
the buffer and then write the contents of the entire buffer to a file
(without making a new string, but lets first get the buffer issue out
of the way), how do I do it?



Thanks,
ssg
 
Reply With Quote
 
 
 
 
bearophileHUGS@lycos.com
Guest
Posts: n/a
 
      11-14-2008
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.

Bye,
bearophile
 
Reply With Quote
 
 
 
 
Aaron Brady
Guest
Posts: n/a
 
      11-14-2008
On Nov 13, 6:40*pm, bearophileH...@lycos.com 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.
>
> Bye,
> bearophile


Also, there is the 'mmap' module.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Treating 'char' Structure Members as Contiguous Bytes Martin C Programming 5 02-11-2008 11:26 AM
Location, location, location =?Utf-8?B?VHJhY2V5?= Wireless Networking 2 02-17-2007 08:37 PM
Memory leak? Private Bytes/Virtual Bytes Ronald ASP General 3 03-09-2005 07:55 PM
Contiguous memory blocks panbru Python 0 08-05-2003 02:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57